From 43d1142f1f86cf364e098f8b32fc294f679fc2b0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 3 Jun 2023 12:40:54 +0100 Subject: [PATCH] 1.19.4 -> 1.20-pre6 --- gradle.properties | 28 +++---- lib/reach-entity-attributes-2.3.3.jar | Bin 0 -> 23920 bytes .../unicopia/EntityConvertable.java | 2 +- .../unicopia/InteractionManager.java | 2 +- .../ability/ChangelingFeedAbility.java | 2 +- .../ability/EarthPonyKickAbility.java | 28 +++---- .../ability/EarthPonyStompAbility.java | 8 +- .../ability/UnicornTeleportAbility.java | 4 +- .../ability/magic/spell/PlaceableSpell.java | 4 +- .../crafting/SpellShapedCraftingRecipe.java | 4 +- .../magic/spell/effect/AttractiveSpell.java | 6 +- .../magic/spell/effect/CatapultSpell.java | 2 +- .../magic/spell/effect/DarkVortexSpell.java | 2 +- .../ability/magic/spell/effect/IceSpell.java | 4 +- .../magic/spell/effect/LightSpell.java | 4 +- .../magic/spell/effect/NecromancySpell.java | 4 +- .../magic/spell/effect/PortalSpell.java | 4 +- .../magic/spell/effect/SiphoningSpell.java | 2 +- .../spell/effect/TransformationSpell.java | 4 +- .../advancement/CustomEventCriterion.java | 6 +- .../advancement/RaceChangeCriterion.java | 6 +- .../block/BaseZapAppleLeavesBlock.java | 3 +- .../block/BlockConstructionUtils.java | 11 +-- .../unicopia/block/FrostedObsidianBlock.java | 6 -- .../unicopia/block/FruitBlock.java | 4 +- .../unicopia/block/SproutBlock.java | 8 +- .../unicopia/block/UBlocks.java | 42 ++++++----- .../block/ZapAppleLeavesPlaceholderBlock.java | 2 +- .../unicopia/block/ZapAppleLogBlock.java | 7 +- .../unicopia/block/state/StatePredicate.java | 5 +- .../unicopia/client/DiscoveryToast.java | 29 +++----- .../client/gui/DismissSpellScreen.java | 20 ++--- .../unicopia/client/gui/DrawableUtil.java | 21 +++--- .../client/gui/ItemTraitsTooltipRenderer.java | 27 +++---- .../client/gui/LanSettingsScreen.java | 10 +-- .../unicopia/client/gui/ManaRingSlot.java | 6 +- .../unicopia/client/gui/SettingsScreen.java | 12 +-- .../unicopia/client/gui/Slot.java | 22 +++--- .../unicopia/client/gui/TextBlock.java | 6 +- .../unicopia/client/gui/TribeButton.java | 15 ++-- .../client/gui/TribeConfirmationScreen.java | 23 +++--- .../client/gui/TribeSelectionScreen.java | 8 +- .../unicopia/client/gui/UHud.java | 70 +++++++++--------- .../client/gui/spellbook/DynamicContent.java | 22 +++--- .../gui/spellbook/EquippedSpellSlot.java | 20 +++-- .../client/gui/spellbook/IngredientTree.java | 40 +++++----- .../client/gui/spellbook/PageElement.java | 16 ++-- .../gui/spellbook/SpellbookChapterList.java | 8 +- .../SpellbookCraftingPageContent.java | 31 ++++---- .../SpellbookProfilePageContent.java | 27 +++---- .../client/gui/spellbook/SpellbookScreen.java | 46 ++++++------ .../SpellbookTraitDexPageContent.java | 45 ++++++----- .../client/minelittlepony/WingsGear.java | 2 +- .../FloatingArtefactEntityRenderer.java | 2 +- .../render/IcarusWingsFeatureRenderer.java | 2 +- .../unicopia/command/DisguiseCommand.java | 8 +- .../unicopia/command/GravityCommand.java | 4 +- .../unicopia/command/RacelistCommand.java | 21 +++--- .../unicopia/command/SpeciesCommand.java | 4 +- .../unicopia/command/TraitCommand.java | 2 +- .../unicopia/command/WorldTribeCommand.java | 8 +- .../compat/emi/SpellbookEmiRecipe.java | 6 +- .../unicopia/compat/emi/TraitEmiStack.java | 18 +++-- .../container/inventory/OutputSlot.java | 2 +- .../unicopia/entity/AirBalloonEntity.java | 8 +- .../unicopia/entity/ButterflyEntity.java | 26 +++---- .../unicopia/entity/CastSpellEntity.java | 2 +- .../unicopia/entity/DynamicLightSource.java | 13 ++-- .../unicopia/entity/EntityPhysics.java | 16 ++-- .../unicopia/entity/FairyEntity.java | 36 ++++----- .../entity/FloatingArtefactEntity.java | 6 +- .../unicopia/entity/ItemImpl.java | 8 +- .../unicopia/entity/ItemPhysics.java | 6 +- .../unicopia/entity/Living.java | 16 ++-- .../entity/PhysicsBodyProjectileEntity.java | 34 ++++----- .../unicopia/entity/SpellbookEntity.java | 22 +++--- .../unicopia/entity/UTradeOffers.java | 2 +- .../unicopia/entity/ai/DynamicTargetGoal.java | 2 +- .../unicopia/entity/ai/EatMuffinGoal.java | 4 +- .../unicopia/entity/ai/WantItTakeItGoal.java | 6 +- .../entity/behaviour/BeeBehaviour.java | 2 +- .../entity/behaviour/BlazeBehaviour.java | 6 +- .../entity/behaviour/ChickenBehaviour.java | 2 +- .../entity/behaviour/EntityBehaviour.java | 4 +- .../unicopia/entity/behaviour/EntitySwap.java | 2 +- .../behaviour/FallingBlockBehaviour.java | 12 +-- .../entity/behaviour/GhastBehaviour.java | 8 +- .../entity/behaviour/MinecartBehaviour.java | 2 +- .../entity/behaviour/MobBehaviour.java | 2 +- .../behaviour/RangedAttackBehaviour.java | 6 +- .../entity/behaviour/SheepBehaviour.java | 10 +-- .../entity/behaviour/ShulkerBehaviour.java | 4 +- .../entity/behaviour/SilverfishBehaviour.java | 6 +- .../SpellcastingIllagerBehaviour.java | 2 +- .../entity/behaviour/TraderBehaviour.java | 2 +- .../entity/collision/EntityCollisions.java | 2 +- .../effect/ButterfingersStatusEffect.java | 10 +-- .../effect/CorruptInfluenceStatusEffect.java | 20 ++--- .../effect/SunBlindnessStatusEffect.java | 2 +- .../entity/player/MeteorlogicalUtil.java | 2 +- .../unicopia/entity/player/PlayerPhysics.java | 52 ++++++------- .../unicopia/entity/player/Pony.java | 10 +-- .../unicopia/item/AlicornAmuletItem.java | 22 +++--- .../unicopia/item/AppleItem.java | 20 ++--- .../unicopia/item/CrystalHeartItem.java | 22 +++--- .../unicopia/item/EnchantableItem.java | 2 +- .../unicopia/item/FilledJarItem.java | 8 +- .../unicopia/item/GlowingRecipe.java | 4 +- .../unicopia/item/ItemCombinationRecipe.java | 6 +- .../unicopia/item/JarInsertRecipe.java | 4 +- .../minelittlepony/unicopia/item/JarItem.java | 38 +++++----- .../unicopia/item/PegasusAmuletItem.java | 4 +- .../unicopia/item/PineappleItem.java | 2 +- .../unicopia/item/StaffItem.java | 6 +- .../minelittlepony/unicopia/item/UItems.java | 3 +- .../unicopia/item/URecipes.java | 2 +- .../unicopia/item/ZapAppleItem.java | 8 +- .../item/group/ItemGroupRegistry.java | 17 +++-- .../unicopia/item/group/UItemGroups.java | 15 ++-- .../unicopia/item/toxin/Toxin.java | 6 +- .../unicopia/mixin/MixinLivingEntity.java | 2 +- .../unicopia/mixin/MixinMobEntity.java | 4 +- .../unicopia/mixin/MixinPlayerEntity.java | 2 +- .../unicopia/mixin/MixinPlayerInventory.java | 2 +- .../mixin/MixinServerPlayNetworkHandler.java | 2 +- .../unicopia/mixin/client/MixinInGameHud.java | 8 +- .../unicopia/network/Channel.java | 2 +- .../network/MsgRequestSpeciesChange.java | 4 +- .../network/MsgSpellbookStateChanged.java | 4 + .../unicopia/particle/ParticleHandle.java | 2 +- .../unicopia/particle/ParticleUtils.java | 2 +- .../projectile/MagicProjectileEntity.java | 14 ++-- .../unicopia/trinkets/UnicopiaTrinket.java | 2 +- .../unicopia/util/SoundEmitter.java | 4 +- .../unicopia/util/TraceHelper.java | 2 +- 135 files changed, 723 insertions(+), 714 deletions(-) create mode 100644 lib/reach-entity-attributes-2.3.3.jar diff --git a/gradle.properties b/gradle.properties index e60405fa..2c9cc03f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.19.4 - yarn_mappings=1.19.4+build.1 - loader_version=0.14.17 - fabric_version=0.76.0+1.19.4 + minecraft_version=1.20-pre6 + yarn_mappings=1.20-pre6+build.2 + loader_version=0.14.21 + fabric_version=0.82.1+1.20 # Mod Properties group=com.minelittlepony @@ -15,19 +15,19 @@ org.gradle.daemon=false description=Magical Abilities for Mine Little Pony! # Publishing - minecraft_version_range=>=1.19.4 + minecraft_version_range=>=1.20.0 modrinth_loader_type=fabric - modrinth_project_id= + modrinth_project_id=9K7RJlvM # Dependencies - fabwork_version=1.1.9 - modmenu_version=6.1.0-rc.4 - minelp_version=4.8.7 - kirin_version=1.14.0 - reach_attributes_version=2.3.2 + fabwork_version=1.2.0 + modmenu_version=7.0.0-beta.2 + minelp_version=4.9.0-beta.2 + kirin_version=1.15.0 + reach_attributes_version=2.3.3 trinkets_version=3.6.0 - terraformer_api_version=6.1.0 + terraformer_api_version=7.0.0-beta.1 # TMI Testing - tmi_type=emi - emi_version=1.0.0+1.19.4 + tmi_type=none + emi_version=1.0.0+1.19.3 diff --git a/lib/reach-entity-attributes-2.3.3.jar b/lib/reach-entity-attributes-2.3.3.jar new file mode 100644 index 0000000000000000000000000000000000000000..40ddce2185dccbe38e21947af9a73a1dce125160 GIT binary patch literal 23920 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 extends WorldConvertable { @Override default World asWorld() { - return asEntity().world; + return asEntity().getWorld(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index 7578967b..609aede2 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -79,7 +79,7 @@ public class InteractionManager { */ @NotNull public final PlayerEntity createPlayer(Entity observer, GameProfile profile) { - return createPlayer(observer.world, profile); + return createPlayer(observer.getWorld(), profile); } /** diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 956e1c4b..660ad410 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -127,7 +127,7 @@ public class ChangelingFeedAbility implements Ability { if (!canFeed(iplayer)) { - iplayer.playSound(SoundEvents.ENTITY_PLAYER_BURP, 1, (float)player.world.random.nextTriangular(1F, 0.2F)); + iplayer.playSound(SoundEvents.ENTITY_PLAYER_BURP, 1, (float)player.getWorld().random.nextTriangular(1F, 0.2F)); } else { iplayer.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.1F, iplayer.getRandomPitch()); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 3d5341f8..3cb12abc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -164,9 +164,9 @@ public class EarthPonyKickAbility implements Ability { PlayerEntity player = iplayer.asEntity(); - if (BlockDestructionManager.of(player.world).getBlockDestruction(pos) + 4 >= BlockDestructionManager.MAX_DAMAGE) { - if (player.world.random.nextInt(30) == 0) { - tree.traverse(player.world, pos, (w, state, p, recurseLevel) -> { + if (BlockDestructionManager.of(player.getWorld()).getBlockDestruction(pos) + 4 >= BlockDestructionManager.MAX_DAMAGE) { + if (player.getWorld().random.nextInt(30) == 0) { + tree.traverse(player.getWorld(), pos, (w, state, p, recurseLevel) -> { if (recurseLevel < 5) { w.breakBlock(p, true); } else { @@ -196,12 +196,12 @@ public class EarthPonyKickAbility implements Ability { } private int dropApples(PlayerEntity player, BlockPos pos) { - TreeType tree = TreeType.at(pos, player.world); + TreeType tree = TreeType.at(pos, player.getWorld()); - if (tree.countBlocks(player.world, pos) > 0) { + if (tree.countBlocks(player.getWorld(), pos) > 0) { List capturedDrops = new ArrayList<>(); - tree.traverse(player.world, pos, (world, state, position, recurse) -> { + tree.traverse(player.getWorld(), pos, (world, state, position, recurse) -> { affectBlockChange(player, position); }, (world, state, position, recurse) -> { affectBlockChange(player, position); @@ -215,7 +215,7 @@ public class EarthPonyKickAbility implements Ability { } }); - capturedDrops.forEach(player.world::spawnEntity); + capturedDrops.forEach(player.getWorld()::spawnEntity); return capturedDrops.size() / 3; } @@ -255,28 +255,28 @@ public class EarthPonyKickAbility implements Ability { } private void affectBlockChange(PlayerEntity player, BlockPos position) { - BlockDestructionManager.of(player.world).damageBlock(position, 4); + BlockDestructionManager.of(player.getWorld()).damageBlock(position, 4); PosHelper.all(position, p -> { - BlockState s = player.world.getBlockState(p); + BlockState s = player.getWorld().getBlockState(p); if (s.getBlock() instanceof BeehiveBlock) { - if (player.world.getBlockEntity(p) instanceof BeehiveBlockEntity hive) { + if (player.getWorld().getBlockEntity(p) instanceof BeehiveBlockEntity hive) { hive.angerBees(player, s, BeehiveBlockEntity.BeeState.EMERGENCY); } - player.world.updateComparators(position, s.getBlock()); + player.getWorld().updateComparators(position, s.getBlock()); Box area = new Box(position).expand(8, 6, 8); - List nearbyBees = player.world.getNonSpectatingEntities(BeeEntity.class, area); + List nearbyBees = player.getWorld().getNonSpectatingEntities(BeeEntity.class, area); if (!nearbyBees.isEmpty()) { - List nearbyPlayers = player.world.getNonSpectatingEntities(PlayerEntity.class, area); + List nearbyPlayers = player.getWorld().getNonSpectatingEntities(PlayerEntity.class, area); int i = nearbyPlayers.size(); for (BeeEntity bee : nearbyBees) { if (bee.getTarget() == null) { - bee.setTarget(nearbyPlayers.get(player.world.random.nextInt(i))); + bee.setTarget(nearbyPlayers.get(player.getWorld().random.nextInt(i))); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 1db144e3..57e56059 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -17,13 +17,13 @@ import com.minelittlepony.unicopia.util.PosHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.Material; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; @@ -148,7 +148,7 @@ public class EarthPonyStompAbility implements Ability { spawnEffectAround(player, center, radius, rad); - ParticleUtils.spawnParticle(player.world, UParticles.GROUND_POUND, player.getX(), player.getY() - 1, player.getZ(), 0, 0, 0); + ParticleUtils.spawnParticle(player.getWorld(), UParticles.GROUND_POUND, player.getX(), player.getY() - 1, player.getZ(), 0, 0, 0); iplayer.subtractEnergyCost(rad); }); @@ -159,7 +159,7 @@ public class EarthPonyStompAbility implements Ability { double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ())); if (dist <= radius) { - spawnEffect(source.world, i, dist, range); + spawnEffect(source.getWorld(), i, dist, range); } }); } @@ -187,7 +187,7 @@ public class EarthPonyStompAbility implements Ability { w.breakBlock(pos, true); if (w instanceof ServerWorld) { - if (state.getMaterial() == Material.STONE && w.getRandom().nextInt(4) == 0) { + if (state.isIn(BlockTags.BASE_STONE_OVERWORLD) && w.getRandom().nextInt(4) == 0) { ItemStack stack = UItems.PEBBLES.getDefaultStack(); stack.setCount(1 + w.getRandom().nextInt(2)); Block.dropStack(w, pos, stack); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 3903d8e9..f8cc8cb1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -168,7 +168,7 @@ public class UnicornTeleportAbility implements Ability { participant.fallDistance /= distance; - participant.world.playSound(null, destination.pos(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); + participant.getWorld().playSound(null, destination.pos(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); } private boolean enterable(World w, BlockPos pos) { @@ -186,7 +186,7 @@ public class UnicornTeleportAbility implements Ability { Block c = state.getBlock(); return state.hasSolidTopSurface(w, pos, player) - || state.getMaterial().isLiquid() + || state.isLiquid() || (c instanceof WallBlock) || (c instanceof FenceBlock) || (c instanceof LeavesBlock); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java index ea6f89da..6f23df66 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java @@ -131,8 +131,8 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS } entity.getSpellSlot().put(copy); entity.setCaster(source); - entity.world.spawnEntity(entity); - Ether.get(entity.world).put(getType(), entity); + entity.getWorld().spawnEntity(entity); + Ether.get(entity.getWorld()).put(getType(), entity); castEntity.set(entity); setDirty(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java index 65791079..cc0dcc0f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java @@ -5,7 +5,7 @@ import com.minelittlepony.unicopia.item.EnchantableItem; import com.minelittlepony.unicopia.item.URecipes; import com.minelittlepony.unicopia.util.InventoryUtil; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.recipe.RecipeSerializer; @@ -20,7 +20,7 @@ public class SpellShapedCraftingRecipe extends ShapedRecipe { } @Override - public ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { return InventoryUtil.stream(inventory) .filter(stack -> stack.getItem() instanceof EnchantableItem) .filter(EnchantableItem::isEnchanted) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 7e824d70..2336c4bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -75,8 +75,8 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp @Override protected boolean isValidTarget(Caster source, Entity entity) { - if (target.isPresent(entity.world)) { - return target.get(entity.world) == entity; + if (target.referenceEquals(entity)) { + return true; } return getTraits().get(Trait.KNOWLEDGE) > 10 ? entity instanceof ItemEntity : super.isValidTarget(source, entity); } @@ -114,7 +114,7 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp z = 0; } - if (this.target.get(target.world) == target) { + if (this.target.referenceEquals(target)) { target.fallDistance = 0; if (target.isOnGround()) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java index c6426c6d..092218cd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java @@ -41,7 +41,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B @Override public void onImpact(MagicProjectileEntity projectile, BlockHitResult hit) { if (!projectile.isClient() && projectile.canModifyAt(hit.getBlockPos())) { - createBlockEntity(projectile.world, hit.getBlockPos(), e -> apply(projectile, e)); + createBlockEntity(projectile.getWorld(), hit.getBlockPos(), e -> apply(projectile, e)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index e10b03a4..bfd2123a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -60,7 +60,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega public void onImpact(MagicProjectileEntity projectile, BlockHitResult hit) { if (!projectile.isClient()) { BlockPos pos = hit.getBlockPos(); - projectile.world.createExplosion(projectile, pos.getX(), pos.getY(), pos.getZ(), 3, ExplosionSourceType.NONE); + projectile.getWorld().createExplosion(projectile, pos.getX(), pos.getY(), pos.getZ(), 3, ExplosionSourceType.NONE); toPlaceable().tick(projectile, Situation.BODY); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java index 428d183e..f5065ff2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java @@ -110,7 +110,7 @@ public class IceSpell extends AbstractSpell { return true; } - if (state.getMaterial() == Material.ICE + if (state.isIn(BlockTags.ICE) && world.random.nextInt(10) == 0 && isSurroundedByIce(world, pos)) { world.setBlockState(pos, Blocks.PACKED_ICE.getDefaultState()); @@ -122,7 +122,7 @@ public class IceSpell extends AbstractSpell { private static boolean isSurroundedByIce(World w, BlockPos pos) { return PosHelper.adjacentNeighbours(pos).allMatch(i -> - w.getBlockState(i).getMaterial() == Material.ICE + w.getBlockState(i).isIn(BlockTags.ICE) ); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java index 0dd8fa74..afa33e74 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java @@ -71,7 +71,7 @@ public class LightSpell extends AbstractSpell implements TimedSpell, ProjectileD return caster.getOriginVector().add(VecHelper.supply(() -> caster.asWorld().random.nextInt(3) - 1)); })); entity.setMaster(caster); - entity.world.spawnEntity(entity); + entity.getWorld().spawnEntity(entity); ref.set(entity); setDirty(); @@ -94,7 +94,7 @@ public class LightSpell extends AbstractSpell implements TimedSpell, ProjectileD } lights.forEach(ref -> { ref.ifPresent(caster.asWorld(), e -> { - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java index 4e7a9882..ddd8f605 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java @@ -99,7 +99,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell implements Projecti summonedEntities.removeIf(ref -> ref.getOrEmpty(source.asWorld()).filter(e -> { if (e.getPos().distanceTo(source.getOriginVector()) > radius * 2) { - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); return false; } @@ -146,7 +146,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell implements Projecti if (master != null) { master.applyDamageEffects(master, e); } - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java index 5ba08dfb..dc0fd4b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java @@ -122,9 +122,9 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme entity.setYaw(entity.getYaw() + yawDifference); entity.setVelocity(entity.getVelocity().rotateY(yawDifference * MathHelper.RADIANS_PER_DEGREE)); - entity.world.playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); entity.teleport(dest.x, dest.y, dest.z); - entity.world.playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); setDirty(); if (!source.subtractEnergyCost(Math.sqrt(entity.getPos().subtract(dest).length()))) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java index 7b6552f3..705533c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java @@ -106,7 +106,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell { } } else { e.heal((float)Math.min(source.getLevel().getScaled(e.getHealth()) / 2F, maxHealthGain * 0.6)); - ParticleUtils.spawnParticle(e.world, new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO); + ParticleUtils.spawnParticle(e.getWorld(), new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java index 237d2f79..b88763c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java @@ -39,11 +39,11 @@ public class TransformationSpell extends AbstractSpell implements ProjectileDele @Override public void onImpact(MagicProjectileEntity projectile, EntityHitResult hit) { - if (projectile.world.isClient) { + if (projectile.getWorld().isClient) { return; } Entity entity = hit.getEntity(); - pickType(entity.getType(), entity.world).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> { + pickType(entity.getType(), entity.getWorld()).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> { entity.playSound(USounds.SPELL_TRANSFORM_TRANSMUTE_ENTITY, 1, 1); }, () -> { ParticleUtils.spawnParticles(ParticleTypes.SMOKE, entity, 20); diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java b/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java index 3ba1ba75..b183cbad 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java @@ -16,7 +16,7 @@ import net.minecraft.advancement.criterion.AbstractCriterionConditions; import net.minecraft.entity.Entity; import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; -import net.minecraft.predicate.entity.EntityPredicate.Extended; +import net.minecraft.predicate.entity.LootContextPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; @@ -31,7 +31,7 @@ public class CustomEventCriterion extends AbstractCriterion races = new HashSet<>(); @@ -73,7 +73,7 @@ public class CustomEventCriterion extends AbstractCriterion races, Boolean flying, int repeatCount) { + public Conditions(LootContextPredicate playerPredicate, String event, Set races, Boolean flying, int repeatCount) { super(ID, playerPredicate); this.event = event; this.races = races; diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java b/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java index 3852453f..42b5dedd 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java @@ -10,7 +10,7 @@ import net.minecraft.advancement.criterion.AbstractCriterionConditions; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; -import net.minecraft.predicate.entity.EntityPredicate.Extended; +import net.minecraft.predicate.entity.LootContextPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; @@ -25,7 +25,7 @@ public class RaceChangeCriterion extends AbstractCriterion type) { @@ -32,15 +33,15 @@ interface BlockConstructionUtils { } static PillarBlock createLogBlock(MapColor topMapColor, MapColor sideMapColor) { - return new PillarBlock(AbstractBlock.Settings.of(Material.WOOD, state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor).strength(2).sounds(BlockSoundGroup.WOOD)); + return new PillarBlock(AbstractBlock.Settings.create().mapColor(state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable()); } static PillarBlock createWoodBlock(MapColor mapColor) { - return new PillarBlock(AbstractBlock.Settings.of(Material.WOOD, mapColor).strength(2).sounds(BlockSoundGroup.WOOD)); + return new PillarBlock(AbstractBlock.Settings.create().mapColor(mapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable()); } static LeavesBlock createLeavesBlock(BlockSoundGroup soundGroup) { - return new LeavesBlock(AbstractBlock.Settings.of(Material.LEAVES).strength(0.2F).ticksRandomly().sounds(soundGroup).nonOpaque().allowsSpawning(BlockConstructionUtils::canSpawnOnLeaves).suffocates(BlockConstructionUtils::never).blockVision(BlockConstructionUtils::never)); + return new LeavesBlock(AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).strength(0.2f).ticksRandomly().sounds(soundGroup).nonOpaque().allowsSpawning(BlockConstructionUtils::canSpawnOnLeaves).suffocates(BlockConstructionUtils::never).blockVision(BlockConstructionUtils::never).burnable().pistonBehavior(PistonBehavior.DESTROY).solidBlock(BlockConstructionUtils::never)); } static Boolean canSpawnOnLeaves(BlockState state, BlockView world, BlockPos pos, EntityType type) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java index 4cc23ee9..07bebabc 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java @@ -7,7 +7,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.FrostedIceBlock; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.stat.Stats; @@ -35,9 +34,4 @@ public class FrostedObsidianBlock extends FrostedIceBlock { world.setBlockState(pos, Blocks.LAVA.getDefaultState()); world.updateNeighbor(pos, Blocks.LAVA, pos); } - - @Override - public PistonBehavior getPistonBehavior(BlockState state) { - return PistonBehavior.BLOCK; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java index 2b3be10c..8313bcf7 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java @@ -6,8 +6,10 @@ import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.minecraft.block.*; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; @@ -30,7 +32,7 @@ public class FruitBlock extends Block implements Buckable { } public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) { - this(settings, attachmentFace, stem, shape, true); + this(settings.sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), attachmentFace, stem, shape, true); } public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape, boolean flammable) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java index ca934c01..ab2eebcf 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java @@ -5,6 +5,7 @@ import java.util.function.Supplier; import org.jetbrains.annotations.Nullable; import net.minecraft.block.*; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; @@ -34,7 +35,12 @@ public class SproutBlock extends CropBlock implements TintedBlock { private final int overlay; public SproutBlock(int overlay, ItemConvertible seeds, Supplier matureState) { - super(Settings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.STEM)); + super(Settings.create() + .noCollision() + .ticksRandomly() + .breakInstantly() + .sounds(BlockSoundGroup.STEM) + .pistonBehavior(PistonBehavior.DESTROY)); this.seeds = seeds; this.matureState = matureState; this.overlay = overlay; diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index 0fbe52e9..02e927e4 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -9,25 +9,27 @@ import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.minelittlepony.unicopia.server.world.UTreeGen; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; import net.minecraft.block.*; import net.minecraft.block.AbstractBlock.Settings; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.*; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.Registries; public interface UBlocks { List TRANSLUCENT_BLOCKS = new ArrayList<>(); - Block ROCKS = register("rocks", new RockCropBlock(FabricBlockSettings.of( - new FabricMaterialBuilder(MapColor.STONE_GRAY).allowsMovement().lightPassesThrough().notSolid().destroyedByPiston().build() - ) + Block ROCKS = register("rocks", new RockCropBlock(Settings.create() + .mapColor(MapColor.STONE_GRAY) + .nonOpaque() + .pistonBehavior(PistonBehavior.DESTROY) .requiresTool() .ticksRandomly() .strength(2) @@ -44,22 +46,22 @@ public interface UBlocks { Block ZAP_LEAVES = register("zap_leaves", new ZapAppleLeavesBlock(), ItemGroups.NATURAL); Block FLOWERING_ZAP_LEAVES = register("flowering_zap_leaves", new BaseZapAppleLeavesBlock(), ItemGroups.NATURAL); Block ZAP_LEAVES_PLACEHOLDER = register("zap_leaves_placeholder", new ZapAppleLeavesPlaceholderBlock()); - Block ZAP_BULB = register("zap_bulb", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); - Block ZAP_APPLE = register("zap_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); + Block ZAP_BULB = register("zap_bulb", new FruitBlock(Settings.create().mapColor(MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); + Block ZAP_APPLE = register("zap_apple", new FruitBlock(Settings.create().mapColor(MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); Block PALM_LOG = register("palm_log", BlockConstructionUtils.createLogBlock(MapColor.OFF_WHITE, MapColor.SPRUCE_BROWN), ItemGroups.BUILDING_BLOCKS); Block PALM_WOOD = register("palm_wood", BlockConstructionUtils.createWoodBlock(MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); Block STRIPPED_PALM_LOG = register("stripped_palm_log", BlockConstructionUtils.createLogBlock(MapColor.OFF_WHITE, MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); Block STRIPPED_PALM_WOOD = register("stripped_palm_wood", BlockConstructionUtils.createWoodBlock(MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); - Block PALM_PLANKS = register("palm_planks", new Block(Settings.of(Material.WOOD, MapColor.OFF_WHITE).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_STAIRS = register("palm_stairs", new StairsBlock(PALM_PLANKS.getDefaultState(), Settings.copy(PALM_PLANKS)), ItemGroups.BUILDING_BLOCKS); - Block PALM_SLAB = register("palm_slab", new SlabBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_FENCE = register("palm_fence", new FenceBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_FENCE_GATE = register("palm_fence_gate", new FenceGateBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD), WoodType.OAK), ItemGroups.BUILDING_BLOCKS); + Block PALM_PLANKS = register("palm_planks", new Block(Settings.create().mapColor(MapColor.OFF_WHITE).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_STAIRS = register("palm_stairs", new StairsBlock(PALM_PLANKS.getDefaultState(), Settings.copy(PALM_PLANKS).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_SLAB = register("palm_slab", new SlabBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_FENCE = register("palm_fence", new FenceBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_FENCE_GATE = register("palm_fence_gate", new FenceGateBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL), WoodType.OAK), ItemGroups.BUILDING_BLOCKS); // Block PALM_DOOR = register("palm_door", new DoorBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(3.0f).sounds(BlockSoundGroup.WOOD).nonOpaque(), SoundEvents.BLOCK_WOODEN_DOOR_CLOSE, SoundEvents.BLOCK_WOODEN_DOOR_OPEN), ItemGroups.BUILDING_BLOCKS); // Block PALM_TRAPDOOR = register("palm_trapdoor", new TrapdoorBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(3.0f).sounds(BlockSoundGroup.WOOD).nonOpaque().allowsSpawning(UBlocks::never), SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, SoundEvents.BLOCK_WOODEN_TRAPDOOR_OPEN), ItemGroups.BUILDING_BLOCKS); - Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD), BlockSetType.OAK), ItemGroups.BUILDING_BLOCKS); + Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), BlockSetType.OAK), ItemGroups.BUILDING_BLOCKS); Block PALM_BUTTON = register("palm_button", BlockConstructionUtils.woodenButton(), ItemGroups.BUILDING_BLOCKS); // Block PALM_SIGN = register("palm_sign", new SignBlock(Settings.of(Material.WOOD).noCollision().strength(1.0f).sounds(BlockSoundGroup.WOOD), PALM_SIGN_TYPE), ItemGroups.BUILDING_BLOCKS); // @@ -69,16 +71,16 @@ public interface UBlocks { Block PALM_LEAVES = register("palm_leaves", BlockConstructionUtils.createLeavesBlock(BlockSoundGroup.GRASS), ItemGroups.BUILDING_BLOCKS); - Block BANANAS = register("bananas", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.YELLOW).sounds(BlockSoundGroup.WOOD).hardness(3), Direction.DOWN, PALM_LEAVES, VoxelShapes.fullCube())); + Block BANANAS = register("bananas", new FruitBlock(Settings.create().mapColor(MapColor.YELLOW).sounds(BlockSoundGroup.WOOD).hardness(3).pistonBehavior(PistonBehavior.DESTROY), Direction.DOWN, PALM_LEAVES, VoxelShapes.fullCube())); - Block WEATHER_VANE = register("weather_vane", new WeatherVaneBlock(FabricBlockSettings.of(Material.METAL, MapColor.BLACK).requiresTool().strength(3.0f, 6.0f).sounds(BlockSoundGroup.METAL).nonOpaque()), ItemGroups.TOOLS); + Block WEATHER_VANE = register("weather_vane", new WeatherVaneBlock(Settings.create().mapColor(MapColor.BLACK).requiresTool().strength(3.0f, 6.0f).sounds(BlockSoundGroup.METAL).nonOpaque().pistonBehavior(PistonBehavior.BLOCK)), ItemGroups.TOOLS); Block GREEN_APPLE_LEAVES = register("green_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), 0xE5FFFF88, () -> UBlocks.GREEN_APPLE, () -> UItems.GREEN_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block GREEN_APPLE = register("green_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, GREEN_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block GREEN_APPLE = register("green_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, GREEN_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block GREEN_APPLE_SPROUT = register("green_apple_sprout", new SproutBlock(0xE5FFFF88, () -> UItems.GREEN_APPLE_SEEDS, () -> UTreeGen.GREEN_APPLE_TREE.sapling().map(Block::getDefaultState).get())); Block SWEET_APPLE_LEAVES = register("sweet_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), @@ -86,7 +88,7 @@ public interface UBlocks { () -> UBlocks.SWEET_APPLE, () -> UItems.SWEET_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block SWEET_APPLE = register("sweet_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block SWEET_APPLE = register("sweet_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block SWEET_APPLE_SPROUT = register("sweet_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SWEET_APPLE_SEEDS, () -> UTreeGen.SWEET_APPLE_TREE.sapling().map(Block::getDefaultState).get())); Block SOUR_APPLE_LEAVES = register("sour_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), @@ -94,10 +96,10 @@ public interface UBlocks { () -> UBlocks.SOUR_APPLE, () -> UItems.SOUR_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block SOUR_APPLE = register("sour_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block SOUR_APPLE = register("sour_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block SOUR_APPLE_SPROUT = register("sour_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SOUR_APPLE_SEEDS, () -> UTreeGen.SOUR_APPLE_TREE.sapling().map(Block::getDefaultState).get())); - Block APPLE_PIE = register("apple_pie", new PieBlock(FabricBlockSettings.of(Material.CAKE, MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS), () -> UItems.APPLE_PIE_SLICE)); + Block APPLE_PIE = register("apple_pie", new PieBlock(Settings.create().solid().mapColor(MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS).pistonBehavior(PistonBehavior.DESTROY), () -> UItems.APPLE_PIE_SLICE)); SegmentedCropBlock OATS = register("oats", SegmentedCropBlock.create(11, 5, AbstractBlock.Settings.copy(Blocks.WHEAT), () -> UItems.OAT_SEEDS, null, () -> UBlocks.OATS_STEM)); SegmentedCropBlock OATS_STEM = register("oats_stem", OATS.createNext(5)); @@ -107,11 +109,11 @@ public interface UBlocks { return register(Unicopia.id(name), item); } - static T register(String name, T block, ItemGroup group) { + static T register(String name, T block, RegistryKey group) { return register(Unicopia.id(name), block, group); } - static T register(Identifier id, T block, ItemGroup group) { + static T register(Identifier id, T block, RegistryKey group) { UItems.register(id, ItemGroupRegistry.register(new BlockItem(block, new Item.Settings()), group)); return register(id, block); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java index 5b23dcde..124ab202 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java @@ -10,7 +10,7 @@ import net.minecraft.util.math.random.Random; public class ZapAppleLeavesPlaceholderBlock extends AirBlock { ZapAppleLeavesPlaceholderBlock() { - super(AbstractBlock.Settings.of(Material.AIR).noCollision().dropsNothing().air()); + super(Settings.create().replaceable().noCollision().dropsNothing().air()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java index 94d2b1c4..69a6eacd 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.block; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.block.*; +import net.minecraft.block.enums.Instrument; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; import net.minecraft.sound.BlockSoundGroup; @@ -18,11 +19,13 @@ public class ZapAppleLogBlock extends PillarBlock { private final Block artifialModelBlock; ZapAppleLogBlock(Block artifialModelBlock, MapColor topMapColor, MapColor sideMapColor) { - super(AbstractBlock.Settings.of(Material.WOOD, + super(AbstractBlock.Settings.create().mapColor( state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor ) + .instrument(Instrument.BASS) + .strength(2.0f) .sounds(BlockSoundGroup.WOOD) - .strength(500, 1200)); + .burnable()); setDefaultState(getDefaultState().with(NATURAL, true)); this.artifialModelBlock = artifialModelBlock; } diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java index 5a6ded9f..2743c01e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java @@ -20,6 +20,7 @@ import net.minecraft.util.JsonHelper; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.registry.tag.TagKey; import net.minecraft.world.World; @@ -123,11 +124,11 @@ public abstract class StatePredicate implements Predicate { } static boolean isWater(BlockState s) { - return s.getMaterial() == Material.WATER; + return s.isLiquid() && s.getFluidState().isIn(FluidTags.WATER); } static boolean isLava(BlockState s) { - return s.getMaterial() == Material.LAVA; + return s.isLiquid() && s.getFluidState().isIn(FluidTags.LAVA); } public static Predicate ofState(String state) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java index 99c6e7e4..51eeb451 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java +++ b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; import org.spongepowered.include.com.google.common.base.Objects; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.toast.Toast; import net.minecraft.client.toast.ToastManager; @@ -26,7 +26,7 @@ public class DiscoveryToast implements Toast { private boolean justUpdated; @Override - public Toast.Visibility draw(MatrixStack matrices, ToastManager manager, long startTime) { + public Toast.Visibility draw(DrawContext context, ToastManager manager, long startTime) { if (justUpdated) { this.startTime = startTime; justUpdated = false; @@ -37,26 +37,21 @@ public class DiscoveryToast implements Toast { } RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, TEXTURE); RenderSystem.setShaderColor(1.0F, 1, 1, 1); - ToastManager.drawTexture(matrices, 0, 0, 0, 32, getWidth(), getHeight()); - manager.getClient().textRenderer.draw(matrices, TITLE, 30, 7, -11534256); - manager.getClient().textRenderer.draw(matrices, DESCRIPTION, 30, 18, -16777216); + + context.drawTexture(TEXTURE, 0, 0, 0, 32, getWidth(), getHeight()); + context.drawText(manager.getClient().textRenderer, TITLE, 30, 7, -11534256, false); + context.drawText(manager.getClient().textRenderer, DESCRIPTION, 30, 18, -16777216, false); Identifier icon = discoveries.get((int)(startTime / Math.max(1L, MAX_AGE / discoveries.size()) % discoveries.size())); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.push(); - matrixStack.scale(0.6F, 0.6F, 1); - RenderSystem.applyModelViewMatrix(); - manager.getClient().getItemRenderer().renderInGui(matrixStack, UItems.SPELLBOOK.getDefaultStack(), 3, 3); - matrixStack.pop(); - RenderSystem.applyModelViewMatrix(); + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.scale(0.6F, 0.6F, 1); + context.drawItem(UItems.SPELLBOOK.getDefaultStack(), 3, 3); + matrices.pop(); - RenderSystem.setShaderTexture(0, icon); - DrawableHelper.drawTexture(matrices, 8, 8, 1, 0, 0, 16, 16, 16, 16); - - // manager.getClient().getItemRenderer().renderInGui(recipe.getOutput(), 8, 8); + context.drawTexture(icon, 8, 8, 1, 0, 0, 16, 16, 16, 16); return startTime - this.startTime >= MAX_AGE ? Toast.Visibility.HIDE : Toast.Visibility.SHOW; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java index a5cfb6e3..1de38b4a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java @@ -72,21 +72,22 @@ public class DismissSpellScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - fillGradient(matrices, 0, 0, width, height / 2, 0xF0101010, 0x80101010); - fillGradient(matrices, 0, height / 2, width, height, 0x80101010, 0xF0101010); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + context.fillGradient(0, 0, width, height / 2, 0xF0101010, 0x80101010); + context.fillGradient(0, height / 2, width, height, 0x80101010, 0xF0101010); relativeMouseX = -width + mouseX * 2; relativeMouseY = -height + mouseY * 2; + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(width - mouseX, height - mouseY, 0); DrawableUtil.drawLine(matrices, 0, 0, relativeMouseX, relativeMouseY, 0xFFFFFF88); DrawableUtil.drawArc(matrices, 40, 80, 0, DrawableUtil.TAU, 0x00000010, false); DrawableUtil.drawArc(matrices, 160, 1600, 0, DrawableUtil.TAU, 0x00000020, false); - super.render(matrices, mouseX, mouseY, delta); - DrawableUtil.renderRaceIcon(matrices, pony.getObservedSpecies(), 0, 0, 16); + super.render(context, mouseX, mouseY, delta); + DrawableUtil.renderRaceIcon(context, pony.getObservedSpecies(), 0, 0, 16); matrices.pop(); DrawableUtil.drawLine(matrices, mouseX, mouseY - 4, mouseX, mouseY + 4, 0xFFAAFF99); @@ -95,7 +96,7 @@ public class DismissSpellScreen extends GameGui { matrices.push(); matrices.translate(0, 0, 300); Text cancel = Text.literal("Press ESC to cancel"); - getFont().drawWithShadow(matrices, cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF); + context.drawText(getFont(), cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF, true); matrices.pop(); } @@ -159,14 +160,15 @@ public class DismissSpellScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); copy.set(x, y, z, w); copy.mul(matrices.peek().getPositionMatrix()); var type = actualSpell.getType().withTraits(actualSpell.getTraits()); DrawableUtil.drawLine(matrices, 0, 0, (int)x, (int)y, 0xFFAAFF99); - DrawableUtil.renderItemIcon(actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), + DrawableUtil.renderItemIcon(context, actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), copy.x - 8 + copy.z / 20F, copy.y - 8 + copy.z / 20F, 1 @@ -199,7 +201,7 @@ public class DismissSpellScreen extends GameGui { } tooltip.add(ScreenTexts.EMPTY); tooltip.add(Text.translatable("[Click to Discard]")); - renderTooltip(matrices, tooltip, 0, 0); + context.drawTooltip(getFont(), tooltip, 0, 0); if (!lastMouseOver) { lastMouseOver = true; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java index 19afcc3b..82cd1958 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java @@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Race; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.GameRenderer; @@ -24,32 +24,29 @@ public interface DrawableUtil { double NUM_RINGS = 300; double INCREMENT = TAU / NUM_RINGS; - static void drawScaledText(MatrixStack matrices, Text text, int x, int y, float size, int color) { + static void drawScaledText(DrawContext context, Text text, int x, int y, float size, int color) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); matrices.scale(size, size, 1); - MinecraftClient.getInstance().textRenderer.draw(matrices, text, 0, 0, color); + context.drawText(MinecraftClient.getInstance().textRenderer, text, 0, 0, color, false); matrices.pop(); } - static void renderItemIcon(ItemStack stack, double x, double y, float scale) { - MatrixStack modelStack = RenderSystem.getModelViewStack(); + static void renderItemIcon(DrawContext context ,ItemStack stack, double x, double y, float scale) { + MatrixStack modelStack = context.getMatrices(); modelStack.push(); modelStack.translate(x, y, 0); if (scale != 1) { modelStack.scale(scale, scale, 1); } - RenderSystem.applyModelViewMatrix(); - - MinecraftClient.getInstance().getItemRenderer().renderGuiItemIcon(modelStack, stack, 0, 0); + context.drawItem(stack, 0, 0); modelStack.pop(); - RenderSystem.applyModelViewMatrix(); } - static void renderRaceIcon(MatrixStack matrices, Race race, int x, int y, int size) { - RenderSystem.setShaderTexture(0, race.getIcon()); - DrawableHelper.drawTexture(matrices, x - size / 2, y - size / 2, 0, 0, 0, size, size, size, size); + static void renderRaceIcon(DrawContext context, Race race, int x, int y, int size) { + context.drawTexture(race.getIcon(), x - size / 2, y - size / 2, 0, 0, 0, size, size, size, size); } static void drawLine(MatrixStack matrices, int x1, int y1, int x2, int y2, int color) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java index 637f4247..e4e304f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java @@ -6,16 +6,14 @@ import java.util.List; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.spell.trait.*; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer.TextLayerType; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.text.*; @@ -54,12 +52,12 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { + public void drawItems(TextRenderer textRenderer, int x, int y, DrawContext context) { int columns = getColumns(); int i = 0; for (var entry : traits) { - renderTraitIcon(entry.getKey(), entry.getValue(), matrices, + renderTraitIcon(entry.getKey(), entry.getValue(), context, x + (i % columns) * 17, y + (i / columns) * 17 ); @@ -82,11 +80,11 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp return Text.empty(); } - public static void renderStackTraits(ItemStack stack, MatrixStack matrices, float x, float y, float weight, float delta, int seed) { - renderStackTraits(SpellTraits.of(stack), matrices, x, y, weight, delta, seed, false); + public static void renderStackTraits(ItemStack stack, DrawContext context, float x, float y, float weight, float delta, int seed) { + renderStackTraits(SpellTraits.of(stack), context, x, y, weight, delta, seed, false); } - public static void renderStackTraits(SpellTraits traits, MatrixStack matrices, float x, float y, float weight, float delta, int seed, boolean revealAll) { + public static void renderStackTraits(SpellTraits traits, DrawContext context, float x, float y, float weight, float delta, int seed, boolean revealAll) { float time = MathHelper.cos((MinecraftClient.getInstance().player.age + delta + seed) / 2F) * 0.7F; float angle = 0.7F + (time / 30F) % MathHelper.TAU; @@ -95,7 +93,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp for (var entry : traits) { if (revealAll || isKnown(entry.getKey())) { - ItemTraitsTooltipRenderer.renderTraitIcon(entry.getKey(), entry.getValue() * weight, matrices, + ItemTraitsTooltipRenderer.renderTraitIcon(entry.getKey(), entry.getValue() * weight, context, x + r * MathHelper.sin(angle), y + r * MathHelper.cos(angle), revealAll || isKnown(entry.getKey()) @@ -110,21 +108,20 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp || Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait); } - public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, float xx, float yy) { - renderTraitIcon(trait, value, matrices, xx, yy, isKnown(trait)); + public static void renderTraitIcon(Trait trait, float value, DrawContext context, float xx, float yy) { + renderTraitIcon(trait, value, context, xx, yy, isKnown(trait)); } - public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, float xx, float yy, boolean reveal) { + public static void renderTraitIcon(Trait trait, float value, DrawContext context, float xx, float yy, boolean reveal) { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; int size = 12; - RenderSystem.setShaderTexture(0, reveal ? trait.getSprite() : UNKNOWN); - + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(xx, yy, 300F); - DrawableHelper.drawTexture(matrices, 2, 1, 0, 0, 0, size, size, size, size); + context.drawTexture(reveal ? trait.getSprite() : UNKNOWN, 2, 1, 0, 0, 0, size, size, size, size); matrices.translate(9, 3 + size / 2, 0); matrices.scale(0.5F, 0.5F, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java index b9a0fac4..866ba85f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java @@ -15,8 +15,8 @@ import com.minelittlepony.unicopia.Config; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Unicopia; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -135,10 +135,10 @@ public class LanSettingsScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, tickDelta); - content.render(matrices, mouseX, mouseY, tickDelta); + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + renderBackground(context); + super.render(context, mouseX, mouseY, tickDelta); + content.render(context, mouseX, mouseY, tickDelta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java index 1b60d28e..2412bb63 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.entity.player.MagicReserves; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; class ManaRingSlot extends Slot { @@ -18,7 +19,8 @@ class ManaRingSlot extends Slot { } @Override - protected void renderContents(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(24.5, 25.5, 0); @@ -58,7 +60,7 @@ class ManaRingSlot extends Slot { matrices.pop(); - super.renderContents(matrices, abilities, bSwap, tickDelta); + super.renderContents(context, abilities, bSwap, tickDelta); } private double renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double offsetAngle, Bar bar, int color, float tickDelta) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java index 39c6775b..15ffad4b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -13,8 +13,8 @@ import com.minelittlepony.unicopia.util.RegistryIndexer; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; @@ -81,7 +81,7 @@ public class SettingsScreen extends GameGui { row += 20; content.addButton(new Label(LEFT, row)).getStyle().setText("unicopia.options.world"); - WorldTribeManager tribes = WorldTribeManager.forWorld((ServerWorld)server.getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid()).world); + WorldTribeManager tribes = WorldTribeManager.forWorld((ServerWorld)server.getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid()).getWorld()); content.addButton(new Slider(LEFT, row += 20, 0, races.size(), races.indexOf(tribes.getDefaultRace()))) .onChange(races.createSetter(tribes::setDefaultRace)) @@ -105,10 +105,10 @@ public class SettingsScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, tickDelta); - content.render(matrices, mouseX, mouseY, tickDelta); + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + renderBackground(context); + super.render(context, mouseX, mouseY, tickDelta); + content.render(context, mouseX, mouseY, tickDelta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java index cc05d25a..e337ddf3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java @@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.client.KeyBindingsHandler; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; @@ -74,7 +75,7 @@ class Slot { return y; } - void renderBackground(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + void renderBackground(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { if (aSlot != bSlot) { bSwap |= !abilities.isFilled(aSlot); @@ -83,17 +84,17 @@ class Slot { RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.enableBlend(); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(getX(), getY(), 0); // background - UHud.drawTexture(matrices, 0, 0, backgroundU, backgroundV, size, size, 128, 128); + context.drawTexture(UHud.HUD_TEXTURE, 0, 0, backgroundU, backgroundV, size, size, 128, 128); AbilityDispatcher.Stat stat = abilities.getStat(bSwap ? bSlot : aSlot); - int sz = iconSize - slotPadding; - uHud.renderAbilityIcon(matrices, stat, slotPadding, slotPadding, sz, sz, sz, sz); + uHud.renderAbilityIcon(context, stat, slotPadding, slotPadding, sz, sz, sz, sz); float cooldown = stat.getFillProgress(); @@ -107,21 +108,22 @@ class Slot { int progressTop = progressBottom - (int)(progressMax * cooldown); // progress - UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF); + context.fill(slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF); } - renderContents(matrices, abilities, bSwap, tickDelta); + renderContents(context, abilities, bSwap, tickDelta); matrices.pop(); } - protected void renderContents(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { // contents - UHud.drawTexture(matrices, 0, 0, foregroundU, foregroundV, size, size, 128, 128); + context.drawTexture(UHud.HUD_TEXTURE, 0, 0, foregroundU, foregroundV, size, size, 128, 128); } - void renderLabel(MatrixStack matrices, AbilityDispatcher abilities, float tickDelta) { + void renderLabel(DrawContext context, AbilityDispatcher abilities, float tickDelta) { Text label = KeyBindingsHandler.INSTANCE.getBinding(aSlot).getLabel(); + MatrixStack matrices = context.getMatrices(); matrices.push(); int x = getX(); @@ -135,7 +137,7 @@ class Slot { matrices.translate(x, getY() + labelY, 0); matrices.scale(0.5F, 0.5F, 0.5F); - UHud.drawTextWithShadow(matrices, uHud.font, label, 0, 0, 0xFFFFFF); + context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true); matrices.pop(); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java index a47fff2e..8943da6e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java @@ -4,7 +4,7 @@ import com.minelittlepony.common.client.gui.dimension.Bounds; import com.minelittlepony.common.client.gui.element.Label; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.OrderedText; public class TextBlock extends Label { @@ -24,11 +24,11 @@ public class TextBlock extends Label { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { int textY = (int)(getY() + MinecraftClient.getInstance().textRenderer.fontHeight/1.5F); for (OrderedText line : getFont().wrapLines(getStyle().getText(), maxWidth)) { - getFont().drawWithShadow(matrices, line, getX(), textY, getStyle().getColor()); + context.drawText(getFont(), line, getX(), textY, getStyle().getColor(), true); textY += getFont().fontHeight; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java index 220366ed..4d6c9204 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java @@ -8,8 +8,8 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -28,9 +28,8 @@ public class TribeButton extends Button { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float partialTicks) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, TribeSelectionScreen.TEXTURE); RenderSystem.setShaderColor(1, 1, 1, alpha); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -41,18 +40,18 @@ public class TribeButton extends Button { MinecraftClient mc = MinecraftClient.getInstance(); - drawTexture(matrices, getX() - 3, getY() - 13, 0, 0, 76, 69); + context.drawTexture(TribeSelectionScreen.TEXTURE, getX() - 3, getY() - 13, 0, 0, 76, 69); if (isHovered()) { - drawTexture(matrices, getX() - 4, getY() - 14, 76, 0, 78, 71); + context.drawTexture(TribeSelectionScreen.TEXTURE, getX() - 4, getY() - 14, 76, 0, 78, 71); if (hovered && screenWidth > 0) { Identifier id = Race.REGISTRY.getId(race); - drawCenteredTextWithShadow(matrices, getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, getY() + height, 0xFFFFFFFF); + context.drawCenteredTextWithShadow(getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, getY() + height, 0xFFFFFFFF); } } if (getStyle().hasIcon()) { - getStyle().getIcon().render(matrices, getX(), getY(), mouseX, mouseY, partialTicks); + getStyle().getIcon().render(context, getX(), getY(), mouseX, mouseY, partialTicks); } int foreColor = getStyle().getColor(); @@ -65,7 +64,7 @@ public class TribeButton extends Button { setMessage(getStyle().getText()); - renderForground(matrices, mc, mouseX, mouseY, foreColor | MathHelper.ceil(alpha * 255.0F) << 24); + renderForground(context, mc, mouseX, mouseY, foreColor | MathHelper.ceil(alpha * 255.0F) << 24); } public static ISprite createSprite(Race race, int x, int y, int size) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java index 75cd0629..44d98451 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java @@ -6,10 +6,9 @@ import com.minelittlepony.common.client.gui.GameGui; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.element.Label; import com.minelittlepony.unicopia.Race; -import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import net.minecraft.util.*; @@ -82,10 +81,8 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - renderBackground(matrices); - - RenderSystem.setShaderTexture(0, TribeSelectionScreen.TEXTURE); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); final int columnHeight = 180; final int columnWidth = 310; @@ -98,23 +95,23 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { final int zOffset = 0; - drawTexture(matrices, left + zOffset, top, 0, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + zOffset, top, 0, 70, 123, columnHeight); - drawTexture(matrices, left + segmentWidth + zOffset, top, 20, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + segmentWidth + zOffset, top, 20, 70, 123, columnHeight); - drawTexture(matrices, width - left - segmentWidth + zOffset, top, 10, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, width - left - segmentWidth + zOffset, top, 10, 70, 123, columnHeight); top -= 31; left = width / 2; - drawTexture(matrices, left - 55, top, 140, 70, 21, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left - 55, top, 140, 70, 21, 50); - drawTexture(matrices, left - 35, top, 10, 70, 69, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left - 35, top, 10, 70, 69, 50); - drawTexture(matrices, left + 35, top, 148, 70, 21, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + 35, top, 148, 70, 21, 50); - super.render(matrices, mouseX, mouseY, delta); + super.render(context, mouseX, mouseY, delta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java index 55c44635..302c546d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java @@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -93,9 +93,9 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, delta); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); + super.render(context, mouseX, mouseY, delta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index d2d9848d..15b61f42 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -22,7 +22,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.util.math.MatrixStack; @@ -35,7 +35,7 @@ import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; -public class UHud extends DrawableHelper { +public class UHud { public static final UHud INSTANCE = new UHud(); @@ -70,7 +70,7 @@ public class UHud extends DrawableHelper { private boolean prevReplacing; private SpellType focusedType = SpellType.empty(); - public void render(InGameHud hud, MatrixStack matrices, float tickDelta) { + public void render(InGameHud hud, DrawContext context, float tickDelta) { if (client.player == null) { return; @@ -81,7 +81,7 @@ public class UHud extends DrawableHelper { Pony pony = Pony.of(client.player); - renderViewEffects(pony, matrices, scaledWidth, scaledHeight, tickDelta); + renderViewEffects(pony, context, scaledWidth, scaledHeight, tickDelta); if (client.currentScreen instanceof HidesHud || client.player.isSpectator() || client.options.hudHidden) { return; @@ -90,6 +90,7 @@ public class UHud extends DrawableHelper { font = client.textRenderer; xDirection = client.player.getMainArm() == Arm.LEFT ? -1 : 1; + MatrixStack matrices = context.getMatrices(); matrices.push(); int hudX = ((scaledWidth - 50) / 2) + (104 * xDirection); @@ -111,7 +112,7 @@ public class UHud extends DrawableHelper { AbilityDispatcher abilities = pony.getAbilities(); if (message != null && messageTime > 0) { - renderMessage(matrices, tickDelta); + renderMessage(context, tickDelta); } RenderSystem.setShaderColor(1, 1, 1,1); @@ -120,7 +121,7 @@ public class UHud extends DrawableHelper { boolean swap = client.options.sneakKey.isPressed(); - slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta)); + slots.forEach(slot -> slot.renderBackground(context, abilities, swap, tickDelta)); if (pony.getObservedSpecies().canCast()) { AbilitySlot slot = swap ? AbilitySlot.PASSIVE : AbilitySlot.PRIMARY; @@ -145,18 +146,18 @@ public class UHud extends DrawableHelper { matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-26)); matrices.scale(0.8F, 0.8F, 1); int u = replacing ? 16 : 3; - UHud.drawTexture(matrices, 0, 0, u, 120, 13, 7, 128, 128); + context.drawTexture(HUD_TEXTURE, 0, 0, u, 120, 13, 7, 128, 128); matrices.pop(); } } - slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta)); + slots.forEach(slot -> slot.renderLabel(context, abilities, tickDelta)); matrices.pop(); if (pony.getObservedSpecies().canCast()) { - renderSpell(pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 10 - xDirection * 13, hudY + 2); - renderSpell(pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 8 - xDirection * 2, hudY - 6); + renderSpell(context, pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 10 - xDirection * 13, hudY + 2); + renderSpell(context, pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 8 - xDirection * 2, hudY - 6); } RenderSystem.disableBlend(); @@ -176,19 +177,16 @@ public class UHud extends DrawableHelper { int x = scaledWidth / 2 + xDirection * 67; int y = (int)(scaledHeight - 18 - dims.height/2F); - MatrixStack view = RenderSystem.getModelViewStack(); - - view.push(); - view.translate(x, y, 0); - view.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xDirection * 45)); - InventoryScreen.drawEntity(view, 0, 0, scale, 0, -20, client.player); - view.pop(); - RenderSystem.applyModelViewMatrix(); + matrices.push(); + matrices.translate(x, y, 0); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xDirection * 45)); + InventoryScreen.drawEntity(context, 0, 0, scale, 0, -20, client.player); + matrices.pop(); }); } } - public void renderSpell(CustomisedSpellType spell, double x, double y) { + public void renderSpell(DrawContext context, CustomisedSpellType spell, double x, double y) { if (spell.isEmpty()) { return; } @@ -196,7 +194,7 @@ public class UHud extends DrawableHelper { Pony pony = Pony.of(client.player); if (spell.isOn(pony)) { - MatrixStack modelStack = new MatrixStack(); + MatrixStack modelStack = context.getMatrices(); modelStack.push(); modelStack.translate(x + 5.5, y + 5.5, 0); @@ -215,17 +213,17 @@ public class UHud extends DrawableHelper { modelStack.push(); modelStack.translate(1, 1, 900); modelStack.scale(0.8F, 0.8F, 0.8F); - font.drawWithShadow(modelStack, count > 64 ? "64+" : String.valueOf(count), 0, 0, 0xFFFFFFFF); + context.drawText(font, count > 64 ? "64+" : String.valueOf(count), 0, 0, 0xFFFFFFFF, true); modelStack.pop(); } modelStack.pop(); } - DrawableUtil.renderItemIcon(spell.getDefaultStack(), x, y, EQUIPPED_GEMSTONE_SCALE); + DrawableUtil.renderItemIcon(context, spell.getDefaultStack(), x, y, EQUIPPED_GEMSTONE_SCALE); } - private void renderMessage(MatrixStack matrices, float tickDelta) { + private void renderMessage(DrawContext context, float tickDelta) { float time = messageTime - tickDelta; int progress = Math.min(255, (int)(time * 255F / 20F)); @@ -235,11 +233,11 @@ public class UHud extends DrawableHelper { color |= alpha; - drawCenteredTextWithShadow(matrices, client.textRenderer, message, 25, -15, color); + context.drawCenteredTextWithShadow(font, message, 25, -15, color); } } - protected void renderViewEffects(Pony pony, MatrixStack matrices, int scaledWidth, int scaledHeight, float tickDelta) { + protected void renderViewEffects(Pony pony, DrawContext context, int scaledWidth, int scaledHeight, float tickDelta) { boolean hasEffect = client.player.hasStatusEffect(UEffects.SUN_BLINDNESS); @@ -258,12 +256,12 @@ public class UHud extends DrawableHelper { int color = 0xFFFFFF; if (hasEffect) { - GradientUtil.fillRadialGradient(matrices, 0, 0, scaledWidth, scaledHeight, + GradientUtil.fillRadialGradient(context.getMatrices(), 0, 0, scaledWidth, scaledHeight, color | (alpha1 << 24), color | (alpha2 << 24), 0, 1); } else { - GradientUtil.fillVerticalGradient(matrices, 0, 0, scaledHeight / 2, scaledWidth, scaledHeight, + GradientUtil.fillVerticalGradient(context.getMatrices(), 0, 0, scaledHeight / 2, scaledWidth, scaledHeight, color | (alpha1 << 24), color | (alpha2 << 24), color | (alpha1 << 24), @@ -277,7 +275,7 @@ public class UHud extends DrawableHelper { final int delay = 7; final int current = client.player.age / delay; final int tint = DyeColor.byId(current % DyeColor.values().length).getSignColor(); - fillGradient(matrices, 0, 0, scaledWidth, scaledHeight, 0x1F000000 | tint, 0x5F000000 | tint); + context.fillGradient(0, 0, scaledWidth, scaledHeight, 0x1F000000 | tint, 0x5F000000 | tint); if (partySound == null || partySound.isDone()) { client.getSoundManager().play( @@ -292,7 +290,7 @@ public class UHud extends DrawableHelper { if (partySound != null) { partySound.setMuted(true); } - fillGradient(matrices, 0, 0, scaledWidth, scaledHeight, 0x0A000088, 0x7E000000); + context.fillGradient(0, 0, scaledWidth, scaledHeight, 0x0A000088, 0x7E000000); } } else { if (partySound != null) { @@ -302,7 +300,7 @@ public class UHud extends DrawableHelper { if (UItems.ALICORN_AMULET.isApplicable(client.player)) { float radius = (float)pony.getArmour().getTicks(UItems.ALICORN_AMULET) / (5 * ItemTracker.DAYS); - renderVignette(matrices, 0x000000, radius, radius, scaledWidth, scaledHeight); + renderVignette(context, 0x000000, radius, radius, scaledWidth, scaledHeight); } float exhaustion = MathHelper.clamp(pony.getMagicalReserves().getExhaustion().getPercentFill(), 0, 0.6F); @@ -319,11 +317,11 @@ public class UHud extends DrawableHelper { float rate = exhaustion > 0.5F ? 2.5F : 7F; float radius = (1 + (float)Math.sin(client.player.age / rate)) / 2F; - renderVignette(matrices, 0x880000, exhaustion * radius, 0.1F + radius * 0.3F, scaledWidth, scaledHeight); + renderVignette(context, 0x880000, exhaustion * radius, 0.1F + radius * 0.3F, scaledWidth, scaledHeight); } } - private void renderVignette(MatrixStack matrices, int color, float alpha, float radius, int scaledWidth, int scaledHeight) { + private void renderVignette(DrawContext context, int color, float alpha, float radius, int scaledWidth, int scaledHeight) { if (radius <= 0) { return; } @@ -331,7 +329,7 @@ public class UHud extends DrawableHelper { color &= 0xFFFFFF; float alpha2 = MathHelper.clamp(radius - 1, 0, 1) * 255; float alpha1 = Math.max(alpha2, MathHelper.clamp(alpha * 2, 0, 1) * 205); - GradientUtil.fillRadialGradient(matrices, 0, 0, scaledWidth, scaledHeight, + GradientUtil.fillRadialGradient(context.getMatrices(), 0, 0, scaledWidth, scaledHeight, color | (int)alpha1 << 24, color | (int)alpha2 << 24, 0, Math.min(1, radius)); @@ -348,11 +346,9 @@ public class UHud extends DrawableHelper { } } - void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { + void renderAbilityIcon(DrawContext context, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { stat.getAbility(Unicopia.getConfig().hudPage.get()).ifPresent(ability -> { - RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player))); - drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); - RenderSystem.setShaderTexture(0, HUD_TEXTURE); + context.drawTexture(ability.getIcon(Pony.of(client.player)), x, y, 0, 0, frameWidth, frameHeight, u, v); }); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java index 80657620..3a5cc878 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java @@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.container.SpellbookChapterLoader.Flow; import com.minelittlepony.unicopia.container.SpellbookState; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.text.Text; @@ -30,17 +31,17 @@ public class DynamicContent implements Content { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int pageIndex = state.getOffset() * 2; - getPage(pageIndex).ifPresent(page -> page.draw(matrices, mouseX, mouseY, container)); + getPage(pageIndex).ifPresent(page -> page.draw(context, mouseX, mouseY, container)); - matrices.push(); + context.getMatrices().push(); getPage(pageIndex + 1).ifPresent(page -> { page.bounds.left = bounds.left + bounds.width / 2 + 20; - page.draw(matrices, mouseX, mouseY, container); + page.draw(context, mouseX, mouseY, container); }); - matrices.pop(); + context.getMatrices().pop(); } @Override @@ -123,7 +124,7 @@ public class DynamicContent implements Content { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { if (elements.isEmpty()) { return; @@ -142,8 +143,9 @@ public class DynamicContent implements Content { int headerColor = mouseY % 255; - DrawableUtil.drawScaledText(matrices, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor); - DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); + MatrixStack matrices = context.getMatrices(); + DrawableUtil.drawScaledText(context, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor); + DrawableUtil.drawScaledText(context, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); matrices.push(); matrices.translate(bounds.left, bounds.top + 16, 0); @@ -151,13 +153,13 @@ public class DynamicContent implements Content { Bounds bounds = element.bounds(); matrices.push(); bounds.translate(matrices); - element.draw(matrices, mouseX, mouseY, container); + element.draw(context, mouseX, mouseY, container); matrices.pop(); }); matrices.push(); elements.stream().filter(PageElement::isInline).forEach(element -> { - element.draw(matrices, mouseX, mouseY, container); + element.draw(context, mouseX, mouseY, container); matrices.translate(0, element.bounds().height, 0); }); matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java index 7dd29a45..c6d3834e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java @@ -9,11 +9,11 @@ import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellTyp import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.item.TooltipContext; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.sound.SoundManager; -import net.minecraft.client.util.math.MatrixStack; public class EquippedSpellSlot extends Button { @@ -33,34 +33,32 @@ public class EquippedSpellSlot extends Button { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.SLOT); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 8, getY() - 8, 0, 0, 32, 32, 32, 32); + context.drawTexture(SpellbookScreen.SLOT, getX() - 8, getY() - 8, 0, 0, 32, 32, 32, 32); Vector4f pos = new Vector4f(getX(), getY(), 0, 1); - pos.mul(matrices.peek().getPositionMatrix()); + pos.mul(context.getMatrices().peek().getPositionMatrix()); if (spell.isEmpty()) { RenderSystem.setShaderColor(1, 1, 1, 0.3F); - RenderSystem.setShaderTexture(0, SpellbookScreen.GEM); - drawTexture(matrices, getX(), getY(), 0, 0, 16, 16, 16, 16); + context.drawTexture(SpellbookScreen.GEM, getX(), getY(), 0, 0, 16, 16, 16, 16); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); } else { RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); - drawItem(matrices, (int)pos.x, (int)pos.y); + drawItem(context, (int)pos.x, (int)pos.y); } if (isHovered()) { - HandledScreen.drawSlotHighlight(matrices, getX(), getY(), 0); + HandledScreen.drawSlotHighlight(context, getX(), getY(), 0); } } - protected void drawItem(MatrixStack matrices, int x, int y) { - itemRenderer.renderInGui(matrices, spell.getDefaultStack(), x, y); + protected void drawItem(DrawContext context, int x, int y) { + context.drawItem(spell.getDefaultStack(), x, y); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java index 737dcabd..d54a80e1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java @@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.client.render.PassThroughVertexConsumer; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.item.TooltipContext; import net.minecraft.client.render.*; import net.minecraft.client.render.item.ItemRenderer; @@ -133,22 +134,22 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.SLOT); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 8, getY() - 10, 0, 0, 32, 32, 32, 32); + context.drawTexture(SpellbookScreen.SLOT, getX() - 8, getY() - 10, 0, 0, 32, 32, 32, 32); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); - MinecraftClient.getInstance().textRenderer.draw(matrices, label, + context.drawText(getFont(), label, getX() - MinecraftClient.getInstance().textRenderer.getWidth(label) / 2 - 3, getY() + 4, - 0 + 0, + false ); - entry.render(matrices, getX(), getY(), tickDelta); + entry.render(context, getX(), getY(), tickDelta); } } @@ -162,7 +163,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { return Multiple.of(Arrays.stream(traits).map(t -> new Traits(t, value)).toArray(Entry[]::new)); } - void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta); + void render(DrawContext context, int mouseX, int mouseY, float tickDelta); Tooltip getTooltip(); @@ -177,7 +178,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { static final IngredientTree.Entry EMPTY = new IngredientTree.Entry() { @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) {} + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) {} @Override public void onClick() { } @@ -203,14 +204,14 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { + public void render(DrawContext context, int x, int y, float tickDelta) { y -= 2; if (ticker++ % 30 == 0) { index = (index + 1) % entries.length; } - entries[index].render(matrices, x, y, tickDelta); + entries[index].render(context, x, y, tickDelta); } @Override @@ -235,12 +236,12 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { - drawItem(matrices, x, y - 2); + public void render(DrawContext context, int x, int y, float tickDelta) { + drawItem(context, x, y - 2); } - protected void drawItem(MatrixStack matrices, int x, int y) { - itemRenderer.renderInGui(matrices, stack, x, y); + protected void drawItem(DrawContext context, int x, int y) { + context.drawItem(stack, x, y); } @Override @@ -261,7 +262,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { static class HiddenStacks extends Stacks { private static final PassThroughVertexConsumer.Parameters FIXTURE = new PassThroughVertexConsumer.Parameters().color((parent, r, g, b, a) -> { - parent.color(0, 0, 0, a); + parent.color(0, 0, 0, 0.6F); }); HiddenStacks(ItemStack stack) { @@ -269,17 +270,18 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - protected void drawItem(MatrixStack matrices, int x, int y) { + protected void drawItem(DrawContext context, int x, int y) { var model = itemRenderer.getModel(stack, null, null, 0); MinecraftClient.getInstance().getTextureManager().getTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).setFilter(false, false); RenderSystem.setShaderTexture(0, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 100); matrices.translate(8, 8, 0); matrices.scale(1, -1, 1); matrices.scale(8, 8, 8); - VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); + VertexConsumerProvider.Immediate immediate = context.getVertexConsumers(); boolean bl = !model.isSideLit(); if (bl) { DiffuseLighting.disableGuiDepthLighting(); @@ -316,8 +318,8 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { - ItemTraitsTooltipRenderer.renderTraitIcon(trait, value, matrices, x, y); + public void render(DrawContext context, int x, int y, float tickDelta) { + ItemTraitsTooltipRenderer.renderTraitIcon(trait, value, context, x, y); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java index 6b7a82fb..b7aea805 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java @@ -11,11 +11,10 @@ import com.minelittlepony.unicopia.client.gui.ParagraphWrappingVisitor; import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookChapterList.Drawable; import com.minelittlepony.unicopia.container.SpellbookChapterLoader.Flow; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.text.Style; @@ -24,7 +23,7 @@ import net.minecraft.util.*; interface PageElement extends Drawable { @Override - default void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + default void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { } @@ -64,10 +63,8 @@ interface PageElement extends Drawable { Bounds bounds, Flow flow) implements PageElement { @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { - RenderSystem.setShaderTexture(0, texture); - DrawableHelper.drawTexture(matrices, 0, 0, 0, 0, 0, bounds().width, bounds().height, bounds().width, bounds().height); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { + context.drawTexture(texture, 0, 0, 0, 0, 0, bounds().width, bounds().height, bounds().width, bounds().height); } } @@ -96,12 +93,13 @@ interface PageElement extends Drawable { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { TextRenderer font = MinecraftClient.getInstance().textRenderer; boolean needsMoreXp = page.getLevel() < 0 || Pony.of(MinecraftClient.getInstance().player).getLevel().get() < page.getLevel(); + MatrixStack matrices = context.getMatrices(); matrices.push(); wrappedText.forEach(line -> { - font.draw(matrices, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0); + context.drawText(font, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0, false); matrices.translate(0, font.fontHeight, 0); }); matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java index cc61d777..72adc98c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java @@ -8,7 +8,7 @@ import com.minelittlepony.common.client.gui.IViewRoot; import com.minelittlepony.unicopia.Debug; import com.minelittlepony.unicopia.Unicopia; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; public class SpellbookChapterList { @@ -89,14 +89,14 @@ public class SpellbookChapterList { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { - obj.draw(matrices, mouseX, mouseY, container); + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { + obj.draw(context, mouseX, mouseY, container); } }); } } public interface Drawable { - void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container); + void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java index 3492fb6b..e2be6444 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java @@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.container.SpellbookState; import com.minelittlepony.unicopia.item.URecipes; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -40,14 +41,14 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int headerColor = mouseY % 255; - DrawableUtil.drawScaledText(matrices, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor); + DrawableUtil.drawScaledText(context, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor); Text pageText = Text.translatable("%s/%s", state.getOffset() + 1, TOTAL_PAGES); - textRenderer.draw(matrices, pageText, 337 - textRenderer.getWidth(pageText) / 2F, 190, headerColor); + context.drawText(textRenderer, pageText, (int)(337 - textRenderer.getWidth(pageText) / 2F), 190, headerColor, false); } @Override @@ -97,35 +98,35 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe } @Override - public void drawOverlays(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void drawOverlays(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(margin.left, margin.top, 0); matrices.translate(-2, -2, 200); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); int tileSize = 25; final int bottom = height - tileSize + 4; final int right = width - tileSize + 9; - drawTexture(matrices, 0, 0, 405, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, 0, 425, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, 0, 405, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, 0, 425, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, bottom, 425, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, bottom, 425, 72, tileSize, tileSize, 512, 256); for (int i = tileSize; i < right; i += tileSize) { - drawTexture(matrices, i, 0, 415, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, i, bottom, 415, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, 0, 415, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, bottom, 415, 72, tileSize, tileSize, 512, 256); } for (int i = tileSize; i < bottom; i += tileSize) { - drawTexture(matrices, 0, i, 405, 67, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, i, 425, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, i, 405, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, i, 425, 67, tileSize, tileSize, 512, 256); } matrices.pop(); - screen.drawSlots(matrices, mouseX, mouseY, tickDelta); + screen.drawSlots(context, mouseX, mouseY, tickDelta); - super.drawOverlays(matrices, mouseX, mouseY, tickDelta); + super.drawOverlays(context, mouseX, mouseY, tickDelta); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java index b01a9169..1c75f655 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java @@ -9,14 +9,14 @@ import com.sollace.romanizer.api.Romanizer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -public class SpellbookProfilePageContent extends DrawableHelper implements SpellbookChapterList.Content { +public class SpellbookProfilePageContent implements SpellbookChapterList.Content { private final MinecraftClient client = MinecraftClient.getInstance(); private final Pony pony = Pony.of(client.player); private final TextRenderer font = client.textRenderer; @@ -63,7 +63,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int y = SpellbookScreen.TITLE_Y; @@ -72,8 +72,8 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell float currentScaledLevel = pony.getLevel().getScaled(1); float currentCorruption = pony.getCorruption().getScaled(1); - DrawableUtil.drawScaledText(matrices, pony.asEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR); - DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel( + DrawableUtil.drawScaledText(context, pony.asEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR); + DrawableUtil.drawScaledText(context, ExperienceGroup.forLevel( currentScaledLevel, currentCorruption ), SpellbookScreen.TITLE_X, y + 13, 0.8F, @@ -85,10 +85,11 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell MagicReserves reserves = pony.getMagicalReserves(); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(screen.getBackgroundWidth() / 2 + SpellbookScreen.TITLE_X - 10, y, 0); matrices.scale(1.3F, 1.3F, 1); - font.draw(matrices, SpellbookCraftingPageContent.INVENTORY_TITLE, 0, 0, SpellbookScreen.TITLE_COLOR); + context.drawText(font, SpellbookCraftingPageContent.INVENTORY_TITLE, 0, 0, SpellbookScreen.TITLE_COLOR, false); matrices.pop(); Bounds bounds = screen.getFrameBounds(); @@ -139,26 +140,26 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell String manaString = (int)reserves.getMana().get() + "/" + (int)reserves.getMana().getMax(); y = 15; - font.draw(matrices, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR); - font.draw(matrices, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR); + context.drawText(font, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR, false); + context.drawText(font, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR, false); Text levelString = Text.literal(Romanizer.romanize(currentLevel + 1)); matrices.translate(-font.getWidth(levelString), -35, 0); matrices.scale(2F, 2F, 1); - font.draw(matrices, levelString, 0, 0, SpellbookScreen.TITLE_COLOR); + context.drawText(font, levelString, 0, 0, SpellbookScreen.TITLE_COLOR, false); matrices.pop(); matrices.push(); matrices.translate(-screen.getX(), -screen.getY(), 0); - screen.drawSlots(matrices, mouseX, mouseY, 0); + screen.drawSlots(context, mouseX, mouseY, 0); matrices.pop(); } - static void drawBar(MatrixStack matrices, int x, int y, float value, int color) { + static void drawBar(DrawContext context, int x, int y, float value, int color) { int barWidth = 40; int midpoint = x + (int)(barWidth * value); - fill(matrices, x, y, midpoint, y + 5, 0xFFAAFFFF); - fill(matrices, midpoint, y, x + barWidth, y + 5, color); + context.fill(x, y, midpoint, y + 5, 0xFFAAFFFF); + context.fill(midpoint, y, x + barWidth, y + 5, color); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java index f45173eb..3419e79b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java @@ -19,6 +19,7 @@ import com.minelittlepony.unicopia.network.MsgSpellbookStateChanged; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; @@ -27,7 +28,6 @@ import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -70,7 +70,7 @@ public class SpellbookScreen extends HandledScreen imple return chapters.getCurrentChapter() == craftingChapter; }); handler.getSpellbookState().setSynchronizer(state -> { - Channel.CLIENT_SPELLBOOK_UPDATE.sendToServer(new MsgSpellbookStateChanged(handler.syncId, state)); + Channel.CLIENT_SPELLBOOK_UPDATE.sendToServer(MsgSpellbookStateChanged.create(handler, state)); }); } @@ -133,21 +133,19 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { if (getState().isDirty()) { clearAndInit(); } - super.render(matrices, mouseX, mouseY, partialTicks); - drawMouseoverTooltip(matrices, mouseX, mouseY); + super.render(context, mouseX, mouseY, partialTicks); } @Override - protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { - renderBackground(matrices); + protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { + renderBackground(context); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, TEXTURE); - drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256); + context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256); if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { clearAndInit(); @@ -169,43 +167,41 @@ public class SpellbookScreen extends HandledScreen imple boolean isRight = tab.chapter().side() == TabSide.RIGHT; - drawTexture(matrices, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); + context.drawTexture(TEXTURE, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderTexture(0, tab.icon().get()); - drawTexture(matrices, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16); + context.drawTexture(TEXTURE, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16); RenderSystem.setShaderTexture(0, TEXTURE); }); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); - chapters.getCurrentChapter().content().ifPresent(content -> content.draw(matrices, mouseX, mouseY, (IViewRoot)this)); + chapters.getCurrentChapter().content().ifPresent(content -> content.draw(context, mouseX, mouseY, (IViewRoot)this)); matrices.pop(); } - void drawSlots(MatrixStack matrices, int mouseX, int mouseY, float delta) { + void drawSlots(DrawContext context, int mouseX, int mouseY, float delta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SLOT); RenderSystem.enableBlend(); for (Slot slot : handler.slots) { if (slot.isEnabled() && slot instanceof SpellbookSlot p) { - drawTexture(matrices, slot.x - 8, slot.y - 8, 0, 0, 32, 32, 32, 32); + context.drawTexture(SLOT, slot.x - 8, slot.y - 8, 0, 0, 32, 32, 32, 32); if (slot instanceof InputSlot) { RenderSystem.setShaderColor(1, 1, 1, 0.3F); - RenderSystem.setShaderTexture(0, GEM); - drawTexture(matrices, slot.x, slot.y, 0, 0, 16, 16, 16, 16); + context.drawTexture(GEM, slot.x, slot.y, 0, 0, 16, 16, 16, 16); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SLOT); } if (!(p instanceof InventorySlot)) { float weight = p.getWeight(); - ItemTraitsTooltipRenderer.renderStackTraits(slot.getStack(), matrices, slot.x, slot.y, weight == 0 ? 1 : weight, delta, slot.id); - RenderSystem.setShaderTexture(0, SLOT); + ItemTraitsTooltipRenderer.renderStackTraits(slot.getStack(), context, slot.x, slot.y, weight == 0 ? 1 : weight, delta, slot.id); RenderSystem.enableBlend(); } } @@ -216,7 +212,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { + protected void drawForeground(DrawContext context, int mouseX, int mouseY) { } @Override @@ -271,7 +267,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { if (!active) { return; } @@ -279,7 +275,7 @@ public class SpellbookScreen extends HandledScreen imple int state = hovered ? 1 : 0; sprite.setTextureOffset(23 * state, (int)(479 + 6.5F - (increment * 6.5F))); - super.renderButton(matrices, mouseX, mouseY, tickDelta); + super.renderButton(context, mouseX, mouseY, tickDelta); } } @@ -294,7 +290,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1, 1, 1, alpha); @@ -304,7 +300,7 @@ public class SpellbookScreen extends HandledScreen imple GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); if (getStyle().hasIcon()) { - getStyle().getIcon().render(matrices, getX(), getY(), mouseX, mouseY, tickDelta); + getStyle().getIcon().render(context, getX(), getY(), mouseX, mouseY, tickDelta); } RenderSystem.setShaderColor(1, 1, 1, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java index f3177bc6..8276e4a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java @@ -16,7 +16,7 @@ import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.*; import net.minecraft.sound.SoundEvents; @@ -24,7 +24,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.Util; -public class SpellbookTraitDexPageContent extends DrawableHelper implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { +public class SpellbookTraitDexPageContent implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { private final Trait[] traits = Trait.values(); private SpellbookState.PageState state = new SpellbookState.PageState(); @@ -40,7 +40,7 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { } @@ -144,42 +144,42 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel @Override - public void drawOverlays(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void drawOverlays(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(margin.left, margin.top, 0); matrices.translate(-2, -2, 200); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); int tileSize = 25; final int bottom = height - tileSize + 4; final int right = width - tileSize + 9; - drawTexture(matrices, 0, 0, 405, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, 0, 405, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); for (int i = tileSize; i < right; i += tileSize) { - drawTexture(matrices, i, 0, 415, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, i, bottom, 415, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, 0, 415, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, bottom, 415, 72, tileSize, tileSize, 512, 256); } for (int i = tileSize; i < bottom; i += tileSize) { - drawTexture(matrices, 0, i, 405, 67, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, i, 425, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, i, 405, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, i, 425, 67, tileSize, tileSize, 512, 256); } - drawTexture(matrices, right, 0, 425, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, bottom, 425, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, 0, 425, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, bottom, 425, 72, tileSize, tileSize, 512, 256); matrices.pop(); if (this == rightPage) { - leftPage.drawDelayed(matrices, mouseX, mouseY, 0); - rightPage.drawDelayed(matrices, mouseX, mouseY, 0); + leftPage.drawDelayed(context, mouseX, mouseY, 0); + rightPage.drawDelayed(context, mouseX, mouseY, 0); } } - public void drawDelayed(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - super.drawOverlays(matrices, mouseX, mouseY, tickDelta); + public void drawDelayed(DrawContext context, int mouseX, int mouseY, float tickDelta) { + super.drawOverlays(context, mouseX, mouseY, tickDelta); } } @@ -199,24 +199,23 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { TraitDiscovery discoveries = Pony.of(MinecraftClient.getInstance().player).getDiscoveries(); setEnabled(discoveries.isKnown(trait)); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 2, getY() - 8, 204, 219, 22, 32, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 2, getY() - 8, 204, 219, 22, 32, 512, 256); if (!active) { - drawTexture(matrices, getX() - 2, getY() - 1, 74, 223, 18, 18, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 2, getY() - 1, 74, 223, 18, 18, 512, 256); } if (discoveries.isUnread(trait)) { - drawTexture(matrices, getX() - 8, getY() - 8, 225, 219, 35, 32, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 8, getY() - 8, 225, 219, 35, 32, 512, 256); } - super.renderButton(matrices, mouseX, mouseY, tickDelta); + super.renderButton(context, mouseX, mouseY, tickDelta); hovered &= active; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java index 754b0d1c..7c759bdc 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java +++ b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java @@ -55,7 +55,7 @@ class WingsGear implements IGear { } if (AmuletSelectors.PEGASUS_AMULET.test(living.asEntity())) { - return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.getWorld().getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; } Race race = living instanceof Pony pony ? pony.getObservedSpecies() : living.getSpecies(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java index 839abd30..e69c12e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java @@ -34,7 +34,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer extends WingsFea @Override protected Identifier getTexture(E entity) { - return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.getWorld().getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index 0eb9a4ff..5fbcd174 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -87,13 +87,13 @@ public class DisguiseCommand { .setDisguise(entity); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.success.self", entity.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.success.self", entity.getName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.disguise.success", entity.getName())); } - source.sendFeedback(Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); } return 0; @@ -114,13 +114,13 @@ public class DisguiseCommand { iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.removed.self"), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.removed.self"), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.disguise.removed")); } - source.sendFeedback(Text.translatable("commands.disguise.removed.other", player.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.removed.other", player.getName()), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java index 61607b62..b0cbeab3 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -60,13 +60,13 @@ class GravityCommand { String translationKey = "commands.gravity." + key; if (source.getEntity() == player) { - source.sendFeedback(Text.translatable(translationKey + ".self", arguments), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".self", arguments), true); } else { if (notifyTarget && source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable(translationKey, arguments)); } - source.sendFeedback(Text.translatable(translationKey + ".other", Streams.concat(Stream.of(player.getDisplayName()), Arrays.stream(arguments)).toArray()), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".other", Streams.concat(Stream.of(player.getDisplayName()), Arrays.stream(arguments)).toArray()), true); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java index fc173e62..6e66b3f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -50,19 +50,20 @@ class RacelistCommand { } static int toggle(ServerCommandSource source, ServerPlayerEntity player, Race race, String action, Function func) { - String translationKey = "commands.racelist." + action; + source.sendFeedback(() -> { + String translationKey = "commands.racelist." + action; - if (!func.apply(race)) { - if (race.isUnset()) { - translationKey = "commands.racelist.illegal"; - } else { - translationKey += ".failed"; + if (!func.apply(race)) { + if (race.isUnset()) { + translationKey = "commands.racelist.illegal"; + } else { + translationKey += ".failed"; + } } - } - Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD); - - source.sendFeedback(Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN), false); + Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD); + return Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN); + }, false); return 0; } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java index 9b61331f..9c5dae7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -72,12 +72,12 @@ class SpeciesCommand { } if (player == source.getPlayer()) { - source.sendFeedback(Text.translatable("commands.race.success.self", race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.race.success.self", race.getDisplayName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.race.success", race.getDisplayName()), false); } - source.sendFeedback(Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true); } } else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.race.permission"), false); diff --git a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java index 2c02dc71..dbda7a73 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java @@ -86,7 +86,7 @@ class TraitCommand { if (source.getPlayer() == player) { player.sendMessage(Text.translatable(translationKey, gravity), false); } else { - source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".other", player.getName(), gravity), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java index b166abd2..933bc4f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java @@ -25,8 +25,10 @@ class WorldTribeCommand { } static int get(ServerCommandSource source) throws CommandSyntaxException { - WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); - source.sendFeedback(Text.translatable("commands.worldtribe.success.get", manager.getDefaultRace().getDisplayName()), true); + source.sendFeedback(() -> { + WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); + return Text.translatable("commands.worldtribe.success.get", manager.getDefaultRace().getDisplayName()); + }, true); return 0; } @@ -34,7 +36,7 @@ class WorldTribeCommand { WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); manager.setDefaultRace(race); - source.sendFeedback(Text.translatable("commands.worldtribe.success.set", race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.worldtribe.success.set", race.getDisplayName()), true); return 0; } } diff --git a/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java b/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java index 58b10365..66329472 100644 --- a/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java @@ -18,7 +18,7 @@ import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.widget.TextureWidget; import dev.emi.emi.api.widget.WidgetHolder; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; @@ -120,9 +120,9 @@ class SpellbookEmiRecipe implements EmiRecipe, SpellbookRecipe.CraftingTreeBuild } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + public void render(DrawContext context, int mouseX, int mouseY, float delta) { RenderSystem.enableBlend(); - super.render(matrices, mouseX, mouseY, delta); + context.drawTexture(texture, x, y, 0, u, v, width, height, textureWidth, textureHeight); } } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java b/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java index 62e2de6c..0d8b2d77 100644 --- a/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java +++ b/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java @@ -14,6 +14,7 @@ import dev.emi.emi.api.render.EmiRender; import dev.emi.emi.api.stack.Comparison; import dev.emi.emi.api.stack.EmiStack; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; @@ -78,25 +79,30 @@ public class TraitEmiStack extends EmiStack { return trait.getName(); } - @Override - public void render(MatrixStack matrices, int x, int y, float delta, int flags) { + //@Override + public void render(DrawContext context, int x, int y, float delta, int flags) { if ((flags & RENDER_ICON) != 0) { List knownItems = trait.getItems(); if (knownItems.isEmpty() || MinecraftClient.getInstance().player == null) { - ItemTraitsTooltipRenderer.renderTraitIcon(trait, amount, matrices, x, y, true); + ItemTraitsTooltipRenderer.renderTraitIcon(trait, amount, context, x, y, true); } else { int tick = (MinecraftClient.getInstance().player.age / 12) % knownItems.size(); ItemStack stack = knownItems.get(tick).getDefaultStack(); - EmiStack.of(stack).render(matrices, x, y, delta, flags); - ItemTraitsTooltipRenderer.renderStackTraits(traits, matrices, x, y, 1, delta, 0, true); + EmiStack.of(stack).render(context.getMatrices(), x, y, delta, flags); + ItemTraitsTooltipRenderer.renderStackTraits(traits, context, x, y, 1, delta, 0, true); } } if ((flags & RENDER_REMAINDER) != 0) { - EmiRender.renderRemainderIcon(this, matrices, x, y); + EmiRender.renderRemainderIcon(this, context.getMatrices(), x, y); } } + //@Override + public void render(MatrixStack matrices, int x, int y, float delta, int flags) { + + } + @Override public EmiStack copy() { return new TraitEmiStack(trait, amount); diff --git a/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java b/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java index 766cbdaa..abf77fad 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java @@ -55,7 +55,7 @@ public class OutputSlot extends CraftingResultSlot implements SpellbookSlot { InventoryUtil.stream(input).forEach(s -> { pony.getDiscoveries().unlock(s.getItem()); }); - pony.getMagicalReserves().getXp().add(MathHelper.clamp(player.world.getRandom().nextFloat() / 10F, 0.001F, 0.3F)); + pony.getMagicalReserves().getXp().add(MathHelper.clamp(player.getWorld().getRandom().nextFloat() / 10F, 0.001F, 0.3F)); super.onTakeItem(player, stack); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java index a5057afb..8e75aa84 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java @@ -80,7 +80,7 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C if (isAirworthy()) { setVelocity(getVelocity() - .add(getWind(world, getBlockPos())) + .add(getWind(getWorld(), getBlockPos())) .normalize() .multiply(0.2) .add(0, isBurnerActive() ? 0.00F : isTouchingWater() ? 0.02F : -0.06F, 0)); @@ -112,15 +112,15 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C if (velocityBeforeTick.length() > 0.01 && !isSubmergedInWater()) { Box box = getInteriorBoundingBox(); - for (Entity e : world.getOtherEntities(this, box.expand(-0.2, 1, -0.2))) { - updatePassenger(e, box, !onGround); + for (Entity e : getWorld().getOtherEntities(this, box.expand(-0.2, 1, -0.2))) { + updatePassenger(e, box, !isOnGround()); weight++; } if (hasBalloon()) { Box balloonBox = getBalloonBoundingBox(); - for (Entity e : world.getOtherEntities(this, balloonBox.expand(1.0E-7))) { + for (Entity e : getWorld().getOtherEntities(this, balloonBox.expand(1.0E-7))) { updatePassenger(e, balloonBox, false); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java index fbb6dfba..72868273 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java @@ -176,17 +176,17 @@ public class ButterflyEntity extends AmbientEntity { return; } - if (world.getBlockState(below).isAir() - || !world.getOtherEntities(this, getBoundingBox().expand(3), this::isAggressor).isEmpty() - || (ticksResting++ > MAX_REST_TICKS || world.random.nextInt(500) == 0) - || world.hasRain(below)) { + if (getWorld().getBlockState(below).isAir() + || !getWorld().getOtherEntities(this, getBoundingBox().expand(3), this::isAggressor).isEmpty() + || (ticksResting++ > MAX_REST_TICKS || getWorld().random.nextInt(500) == 0) + || getWorld().hasRain(below)) { setResting(false); return; } - if (!world.isClient + if (!getWorld().isClient && age % BREEDING_INTERVAL == 0 - && world.random.nextInt(200) == 0 + && getWorld().random.nextInt(200) == 0 && canBreed()) { breed(); } @@ -205,14 +205,14 @@ public class ButterflyEntity extends AmbientEntity { return flower; }).or(this::findNextHoverPosition).ifPresent(this::moveTowards); - if (random.nextInt(100) == 0 && world.getBlockState(below).isOpaque()) { + if (random.nextInt(100) == 0 && getWorld().getBlockState(below).isOpaque()) { setResting(true); } } } private boolean canBreed() { - return age > BREEDING_INTERVAL && breedingCooldown <= 0 && isResting() && world.getOtherEntities(this, getBoundingBox().expand(2), i -> { + return age > BREEDING_INTERVAL && breedingCooldown <= 0 && isResting() && getWorld().getOtherEntities(this, getBoundingBox().expand(2), i -> { return i instanceof ButterflyEntity && i.getType() == getType() && ((ButterflyEntity)i).isResting(); }).size() == 1; } @@ -220,9 +220,9 @@ public class ButterflyEntity extends AmbientEntity { private boolean breed() { breedingCooldown = MAX_BREEDING_COOLDOWN; - ButterflyEntity copy = (ButterflyEntity)getType().create(world); + ButterflyEntity copy = (ButterflyEntity)getType().create(getWorld()); copy.copyPositionAndRotation(this); - world.spawnEntity(copy); + getWorld().spawnEntity(copy); setResting(false); return true; } @@ -231,7 +231,7 @@ public class ButterflyEntity extends AmbientEntity { // invalidate the hovering position BlockPos pos = getBlockPos(); - return hoveringPosition = hoveringPosition.filter(p -> world.isAir(p) + return hoveringPosition = hoveringPosition.filter(p -> getWorld().isAir(p) && p.getY() >= 1 && random.nextInt(30) != 0 && p.getSquaredDistance(pos) >= 4).or(() -> { @@ -249,9 +249,9 @@ public class ButterflyEntity extends AmbientEntity { return flowerPosition; } - flowerPosition = flowerPosition.filter(p -> world.getBlockState(p).isIn(BlockTags.FLOWERS)).or(() -> { + flowerPosition = flowerPosition.filter(p -> getWorld().getBlockState(p).isIn(BlockTags.FLOWERS)).or(() -> { return BlockPos.streamOutwards(getBlockPos(), FLOWER_DETECTION_RANGE, FLOWER_DETECTION_RANGE, FLOWER_DETECTION_RANGE) - .filter(p -> !visited.containsKey(p) && world.getBlockState(p).isIn(BlockTags.FLOWERS)) + .filter(p -> !visited.containsKey(p) && getWorld().getBlockState(p).isIn(BlockTags.FLOWERS)) .findFirst() .map(p -> { visited.put(p, (long)age - 900); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java index a9364259..63592f7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -67,7 +67,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster Operation.ofBoolean(spell.tick(this, Situation.GROUND_ENTITY)), world.isClient)) { + if (!getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.GROUND_ENTITY)), getWorld().isClient)) { discard(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java b/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java index 6ce8ce7e..112a5087 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java @@ -22,7 +22,7 @@ public interface DynamicLightSource { @SuppressWarnings("deprecation") void tick() { - if (entity.world.isClient) { + if (entity.getWorld().isClient) { if (entity.isRemoved()) { remove(); return; @@ -36,12 +36,13 @@ public interface DynamicLightSource { BlockPos currentPos = entity.getBlockPos(); - if (!currentPos.equals(lastPos) && entity.world.isChunkLoaded(currentPos)) { + if (!currentPos.equals(lastPos) && entity.getWorld().isChunkLoaded(currentPos)) { try { if (lastPos != null) { - entity.world.getLightingProvider().checkBlock(lastPos); + entity.getWorld().getLightingProvider().checkBlock(lastPos); } - entity.world.getLightingProvider().addLightSource(currentPos, light); + // TODO: store this in the ether and inject into Chunk#forEachLightSource + //entity.getWorld().getLightingProvider().addLightSource(currentPos, light); lastPos = currentPos; } catch (Exception ignored) { } } @@ -49,9 +50,9 @@ public interface DynamicLightSource { } void remove() { - if (entity.world.isClient && lastPos != null) { + if (entity.getWorld().isClient && lastPos != null) { try { - entity.world.getLightingProvider().checkBlock(lastPos); + entity.getWorld().getLightingProvider().checkBlock(lastPos); } catch (Exception ignored) {} } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java index 4bc6b8f7..679ea0ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java @@ -42,7 +42,7 @@ public class EntityPhysics implements Physics, Copyable entity.world.getHeight() + 64) { + if (entity.getY() > entity.getWorld().getHeight() + 64) { entity.damage(entity.getDamageSources().outOfWorld(), 4.0F); } @@ -60,7 +60,7 @@ public class EntityPhysics implements Physics, Copyable implements Physics, Copyable implements Physics, Copyable 100) { teleport( - target.getX() + world.random.nextFloat() / 2F - 0.5F, + target.getX() + getWorld().random.nextFloat() / 2F - 0.5F, target.getEyeY(), - target.getZ() + world.random.nextFloat() / 2F - 0.5F + target.getZ() + getWorld().random.nextFloat() / 2F - 0.5F ); setVelocity(target.getVelocity()); return; @@ -331,7 +331,7 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource, if (distance <= minDistance * minDistance) { - BlockPos pos = FuzzyPositions.localFuzz(FairyEntity.this.world.random, 5, 5); + BlockPos pos = FuzzyPositions.localFuzz(getWorld().random, 5, 5); if (pos != null) { getNavigation().startMovingTo(pos.getX(), pos.getY(), pos.getZ(), speed); } else { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java index 6fdf43b6..d1ea98e4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java @@ -98,7 +98,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { setStack(UItems.EMPTY_JAR.getDefaultStack()); } - if (world.isClient) { + if (getWorld().isClient) { float spin = getSpin(); if (Math.abs(spin - targetSpin) > 1.0E-5F) { spinChange = spin - targetSpin; @@ -129,7 +129,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { ((Artifact)stack.getItem()).onArtifactTick(this); } - if (world.getTime() % 80 == 0) { + if (getWorld().getTime() % 80 == 0) { State state = getState(); playSound(USounds.ENTITY_ARTEFACT_AMBIENT, state.getVolume(), state.getPitch()); } @@ -193,7 +193,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { @Override public World asWorld() { - return world; + return getWorld(); } public enum State { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java index 1777d7dc..92fe5549 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java @@ -49,7 +49,7 @@ public class ItemImpl implements Equine { @Override public boolean beforeUpdate() { - if (!entity.world.isClient) { + if (!entity.getWorld().isClient) { Race race = getSpecies(); if (race != serverRace) { serverRace = race; @@ -67,9 +67,9 @@ public class ItemImpl implements Equine { ClingyItem clingy = item instanceof ClingyItem ? (ClingyItem)item : ClingyItem.DEFAULT; if (clingy.isClingy(stack)) { - Random rng = entity.world.random; + Random rng = entity.getWorld().random; - entity.world.addParticle(clingy.getParticleEffect((IItemEntity)entity), + entity.getWorld().addParticle(clingy.getParticleEffect((IItemEntity)entity), entity.getX() + rng.nextFloat() - 0.5, entity.getY() + rng.nextFloat() - 0.5, entity.getZ() + rng.nextFloat() - 0.5, @@ -77,7 +77,7 @@ public class ItemImpl implements Equine { ); Vec3d position = entity.getPos(); - VecHelper.findInRange(entity, entity.world, entity.getPos(), clingy.getFollowDistance(i), e -> e instanceof PlayerEntity) + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), clingy.getFollowDistance(i), e -> e instanceof PlayerEntity) .stream() .sorted((a, b) -> (int)(a.getPos().distanceTo(position) - b.getPos().distanceTo(position))) .findFirst() diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java index 5464dea5..f1675f0d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java @@ -25,7 +25,7 @@ class ItemPhysics extends EntityPhysics { float above = 0.98f; if (entity.verticalCollision) { - above *= entity.world.getBlockState(entity.getBlockPos().up()).getBlock().getSlipperiness(); + above *= entity.getWorld().getBlockState(entity.getBlockPos().up()).getBlock().getSlipperiness(); //above /= 9; } @@ -36,8 +36,8 @@ class ItemPhysics extends EntityPhysics { @Override protected void onGravitychanged() { - if (!entity.world.isClient) { - float gravity = this.getBaseGravityModifier(); + if (!entity.getWorld().isClient) { + float gravity = getBaseGravityModifier(); setBaseGravityModifier(gravity == 0 ? 1 : gravity * 2); setBaseGravityModifier(gravity); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 8650adb4..2bf7cbf2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -170,7 +170,7 @@ public abstract class Living implements Equine, Caste tickers.forEach(Tickable::tick); try { - getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient); + getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.getWorld().isClient); } catch (Exception e) { Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", entity, e); } @@ -223,12 +223,12 @@ public abstract class Living implements Equine, Caste } private void updateDragonBreath() { - if (!entity.world.isClient && (entity instanceof PlayerEntity || entity.hasCustomName())) { + if (!entity.getWorld().isClient && (entity instanceof PlayerEntity || entity.hasCustomName())) { Vec3d targetPos = entity.getRotationVector().multiply(2).add(entity.getEyePos()); if (entity.getWorld().isAir(BlockPos.ofFloored(targetPos))) { - DragonBreathStore store = DragonBreathStore.get(entity.world); + DragonBreathStore store = DragonBreathStore.get(entity.getWorld()); String name = entity.getDisplayName().getString(); store.popEntries(name).forEach(stack -> { Vec3d randomPos = targetPos.add(VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5))); @@ -238,16 +238,16 @@ public abstract class Living implements Equine, Caste } for (int i = 0; i < 10; i++) { - ParticleUtils.spawnParticle(entity.world, ParticleTypes.FLAME, randomPos.add( + ParticleUtils.spawnParticle(entity.getWorld(), ParticleTypes.FLAME, randomPos.add( VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5)) ), Vec3d.ZERO); } - ItemEntity item = EntityType.ITEM.create(entity.world); + ItemEntity item = EntityType.ITEM.create(entity.getWorld()); item.setStack(stack.payload()); item.setPosition(randomPos); - item.world.spawnEntity(item); - entity.world.playSoundFromEntity(null, entity, USounds.ITEM_DRAGON_BREATH_ARRIVE, entity.getSoundCategory(), 1, 1); + item.getWorld().spawnEntity(item); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ITEM_DRAGON_BREATH_ARRIVE, entity.getSoundCategory(), 1, 1); if (stack.payload().getItem() == UItems.OATS && entity instanceof PlayerEntity player) { UCriteria.RECEIVE_OATS.trigger(player); @@ -395,7 +395,7 @@ public abstract class Living implements Equine, Caste } public static void transmitPassengers(@Nullable Entity entity) { - if (entity != null && entity.world instanceof ServerWorld sw) { + if (entity != null && entity.getWorld() instanceof ServerWorld sw) { sw.getChunkManager().sendToNearbyPlayers(entity, new EntityPassengersSetS2CPacket(entity)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java index 1de7dc8e..30357a43 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java @@ -107,7 +107,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl @Override public void onPlayerCollision(PlayerEntity player) { - if (world.isClient || isNoClip() || shake > 0) { + if (getWorld().isClient || isNoClip() || shake > 0) { return; } @@ -132,26 +132,26 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl @Override protected void onBlockHit(BlockHitResult hit) { - BlockState state = world.getBlockState(hit.getBlockPos()); + BlockState state = getWorld().getBlockState(hit.getBlockPos()); BlockState posState = getBlockStateAtPos(); if (state.isIn(BlockTags.WOODEN_BUTTONS) && state.getBlock() instanceof ButtonBlock button) { - button.powerOn(state, world, hit.getBlockPos()); + button.powerOn(state, getWorld(), hit.getBlockPos()); } else if (posState.isIn(BlockTags.WOODEN_BUTTONS) && posState.getBlock() instanceof ButtonBlock button) { - button.powerOn(posState, world, getBlockPos()); + button.powerOn(posState, getWorld(), getBlockPos()); } if (state.getBlock() instanceof LeverBlock lever) { - lever.togglePower(state, world, hit.getBlockPos()); + lever.togglePower(state, getWorld(), hit.getBlockPos()); } else if (posState.getBlock() instanceof LeverBlock lever) { - lever.togglePower(posState, world, getBlockPos()); + lever.togglePower(posState, getWorld(), getBlockPos()); } BlockPos belowPos = getBlockPos().down(); - BlockState below = world.getBlockState(belowPos); + BlockState below = getWorld().getBlockState(belowPos); ItemStack stack = getStack(); if (below.getBlock() instanceof HopperBlock hopper) { - BlockEntity e = world.getBlockEntity(belowPos); + BlockEntity e = getWorld().getBlockEntity(belowPos); if (e instanceof Inventory inventory) { for (int i = 0; i < inventory.size(); i++) { ItemStack slotStack = inventory.getStack(i); @@ -171,18 +171,18 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } if (getVelocity().length() > 0.2F) { - boolean ownerCanModify = !world.isClient && Caster.of(getOwner()).filter(pony -> pony.canModifyAt(hit.getBlockPos())).isPresent(); + boolean ownerCanModify = !getWorld().isClient && Caster.of(getOwner()).filter(pony -> pony.canModifyAt(hit.getBlockPos())).isPresent(); - if (ownerCanModify && world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { - if ((!isBouncy() || world.random.nextInt(200) == 0) && state.isIn(UTags.FRAGILE)) { - world.breakBlock(hit.getBlockPos(), true); + if (ownerCanModify && getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { + if ((!isBouncy() || getWorld().random.nextInt(200) == 0) && state.isIn(UTags.FRAGILE)) { + getWorld().breakBlock(hit.getBlockPos(), true); } } if (isBouncy()) { Direction.Axis side = hit.getSide().getAxis(); - double randomisation = ((world.random.nextFloat() - 0.5F) / 5); + double randomisation = ((getWorld().random.nextFloat() - 0.5F) / 5); double inflectionAmount = randomisation + -0.4; double deflectionAmount = randomisation + 0.3; @@ -200,9 +200,9 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } addVelocity( - ((world.random.nextFloat() - 0.5F) / 5), - ((world.random.nextFloat() - 0.5F) / 5), - ((world.random.nextFloat() - 0.5F) / 5) + ((getWorld().random.nextFloat() - 0.5F) / 5), + ((getWorld().random.nextFloat() - 0.5F) / 5), + ((getWorld().random.nextFloat() - 0.5F) / 5) ); } else { super.onBlockHit(hit); @@ -212,7 +212,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } setSound(state.getSoundGroup().getStepSound()); - world.playSoundFromEntity(null, this, state.getSoundGroup().getStepSound(), SoundCategory.BLOCKS, 1, 1); + getWorld().playSoundFromEntity(null, this, state.getSoundGroup().getStepSound(), SoundCategory.BLOCKS, 1, 1); emitGameEvent(GameEvent.STEP); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java index dbe0b289..8b0b5452 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java @@ -58,7 +58,7 @@ public class SpellbookEntity extends MobEntity { if (player instanceof ServerPlayerEntity recipient && player.currentScreenHandler instanceof SpellbookScreenHandler book && getUuid().equals(book.entityId)) { - Channel.SERVER_SPELLBOOK_UPDATE.sendToPlayer(new MsgSpellbookStateChanged(book.syncId, state), recipient); + Channel.SERVER_SPELLBOOK_UPDATE.sendToPlayer(new MsgSpellbookStateChanged<>(book.syncId, state), recipient); } }); }); @@ -143,7 +143,7 @@ public class SpellbookEntity extends MobEntity { jumping = awake && isTouchingWater(); super.tick(); - if (world.isClient && isOpen()) { + if (getWorld().isClient && isOpen()) { for (int offX = -2; offX <= 1; ++offX) { for (int offZ = -2; offZ <= 1; ++offZ) { if (offX > -1 && offX < 1 && offZ == -1) { @@ -152,7 +152,7 @@ public class SpellbookEntity extends MobEntity { if (random.nextInt(320) == 0) { for (int offY = 0; offY <= 1; ++offY) { - world.addParticle(ParticleTypes.ENCHANT, + getWorld().addParticle(ParticleTypes.ENCHANT, getX(), getY(), getZ(), offX/2F + random.nextFloat(), offY/2F - random.nextFloat() + 0.5f, @@ -165,7 +165,7 @@ public class SpellbookEntity extends MobEntity { } if (awake) { - world.getOtherEntities(this, getBoundingBox().expand(2), EquinePredicates.PLAYER_UNICORN.and(e -> e instanceof PlayerEntity)).stream().findFirst().ifPresent(player -> { + getWorld().getOtherEntities(this, getBoundingBox().expand(2), EquinePredicates.PLAYER_UNICORN.and(e -> e instanceof PlayerEntity)).stream().findFirst().ifPresent(player -> { setBored(false); if (isOpen()) { Vec3d diff = player.getPos().subtract(getPos()); @@ -176,15 +176,15 @@ public class SpellbookEntity extends MobEntity { } }); - if (!world.isClient) { + if (!getWorld().isClient) { if (activeTicks > 0 && --activeTicks <= 0) { setBored(true); } } } - if (!world.isClient && world.random.nextInt(30) == 0) { - float celest = world.getSkyAngle(1) * 4; + if (!getWorld().isClient && getWorld().random.nextInt(30) == 0) { + float celest = getWorld().getSkyAngle(1) * 4; boolean daytime = celest > 3 || celest < 1; @@ -198,14 +198,14 @@ public class SpellbookEntity extends MobEntity { @Override public boolean damage(DamageSource source, float amount) { - if (!world.isClient) { + if (!getWorld().isClient) { remove(Entity.RemovalReason.KILLED); BlockSoundGroup sound = BlockSoundGroup.WOOD; - world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); + getWorld().playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); - if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { + if (getWorld().getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { dropStack(getPickBlockStack(), 1); } } @@ -232,7 +232,7 @@ public class SpellbookEntity extends MobEntity { @Override public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { - return new SpellbookScreenHandler(syncId, inv, ScreenHandlerContext.create(world, getBlockPos()), state, getUuid()); + return new SpellbookScreenHandler(syncId, inv, ScreenHandlerContext.create(getWorld(), getBlockPos()), state, getUuid()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java index 26721e32..612d0480 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java @@ -87,7 +87,7 @@ public interface UTradeOffers { } private static Item random(Entity e, TagKey item, Random rng) { - return RegistryUtils.entriesForTag(e.world, item).getRandom(rng).get().value(); + return RegistryUtils.entriesForTag(e.getWorld(), item).getRandom(rng).get().value(); } static class JarredItemTradeOfferFactory implements TradeOffers.Factory { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java index 0103b766..d4f8133c 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java @@ -52,7 +52,7 @@ public class DynamicTargetGoal extends Goal { mob.setTarget(null); } - target = VecHelper.findInRange(mob, mob.world, mob.getPos(), 26, test) + target = VecHelper.findInRange(mob, mob.getWorld(), mob.getPos(), 26, test) .stream() .sorted(Comparator.comparing(e -> mob.distanceTo(e))) .findFirst(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java index 5f9880c0..255a4c68 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java @@ -66,11 +66,11 @@ public class EatMuffinGoal extends BreakHeartGoal { eatingStarted = true; if (target instanceof PhysicsBodyProjectileEntity projectile) { - mob.eatFood(mob.world, projectile.getStack()); + mob.eatFood(mob.getWorld(), projectile.getStack()); projectile.discard(); if (mob instanceof AnimalEntity animal) { - if (mob.world.random.nextInt(12) == 0) { + if (mob.getWorld().random.nextInt(12) == 0) { Entity player = ((PhysicsBodyProjectileEntity) target).getOwner(); animal.lovePlayer(player instanceof PlayerEntity ? (PlayerEntity)player : null); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java index 2e92d5cb..3fdb9cf2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java @@ -62,11 +62,11 @@ public class WantItTakeItGoal extends BreakHeartGoal { mob.tryAttack(target); mob.swingHand(Hand.MAIN_HAND); - if (mob.world.random.nextInt(20) == 0) { + if (mob.getWorld().random.nextInt(20) == 0) { for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack stack = ((LivingEntity)target).getEquippedStack(slot); if (EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, stack) > 0) { - AwaitTickQueue.scheduleTask(mob.world, w -> { + AwaitTickQueue.scheduleTask(mob.getWorld(), w -> { target.equipStack(slot, ItemStack.EMPTY); mob.tryEquip(stack); }); @@ -76,7 +76,7 @@ public class WantItTakeItGoal extends BreakHeartGoal { } } } else if (target instanceof ItemEntity) { - AwaitTickQueue.scheduleTask(mob.world, w -> { + AwaitTickQueue.scheduleTask(mob.getWorld(), w -> { ItemEntity item = (ItemEntity)target; ItemStack stack = item.getStack(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java index 1252fd52..8cdc1901 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java @@ -9,7 +9,7 @@ public class BeeBehaviour extends EntityBehaviour { @Override public BeeEntity onCreate(BeeEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); - if (replaceOld && entity.world.isClient) { + if (replaceOld && entity.getWorld().isClient) { InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_BEE, entity.getId()); } return entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java index f7e81bef..7df21f65 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java @@ -67,19 +67,19 @@ public class BlazeBehaviour extends EntityBehaviour { if (fireballsFired > 0) { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0); } Vec3d rot = player.asEntity().getRotationVec(1); for (int i = 0; i < 1; ++i) { - SmallFireballEntity proj = new SmallFireballEntity(entity.world, player.asEntity(), + SmallFireballEntity proj = new SmallFireballEntity(entity.getWorld(), player.asEntity(), rot.getX() + entity.getRandom().nextGaussian(), rot.getY(), rot.getZ() + entity.getRandom().nextGaussian() ); proj.setPosition(proj.getX(), entity.getBodyY(0.5D) + 0.5D, proj.getZ()); - entity.world.spawnEntity(proj); + entity.getWorld().spawnEntity(proj); } } } else if (!firing) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java index f31f2904..45eb0668 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java @@ -36,7 +36,7 @@ public class ChickenBehaviour extends EntityBehaviour { player.asEntity().getInventory().removeStack(slot, 1); entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1, - (entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F + 4 + (entity.getWorld().random.nextFloat() - entity.getWorld().random.nextFloat()) * 0.2F + 4 ); entity.equipStack(EquipmentSlot.OFFHAND, egg); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index 21fbbdcf..7024f9aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -110,7 +110,7 @@ public class EntityBehaviour { ((EntityDuck)to).setRemovalReason(from.getRemovalReason()); to.setOnGround(from.isOnGround()); - if (!from.world.isClient) { + if (!from.getWorld().isClient) { // player collision is not known on the server boolean clip = to.noClip; to.noClip = false; @@ -134,7 +134,7 @@ public class EntityBehaviour { BlockPos pos = BlockPos.ofFloored(x, y, z); - if (!from.world.isAir(pos) && !from.world.isWater(pos)) { + if (!from.getWorld().isAir(pos) && !from.getWorld().isWater(pos)) { y++; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java index bc411313..9ed861e7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java @@ -30,7 +30,7 @@ public interface EntitySwap { Swap YAW = Swap.of(Entity::getYaw, Entity::setYaw); Swap HEAD_YAW = Swap.of(Entity::getHeadYaw, (entity, headYaw) -> { entity.setHeadYaw(headYaw); - if (entity.world instanceof ServerWorld sw) { + if (entity.getWorld() instanceof ServerWorld sw) { sw.getChunkManager().sendToNearbyPlayers(entity, new EntitySetHeadYawS2CPacket(entity, (byte)MathHelper.floor(entity.getHeadYaw() * 256F / 360F))); } }); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java index e70103b9..bc3fafd2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -48,7 +48,7 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState state = entity.getBlockState(); if (state.getBlock() instanceof FallingBlock fb) { - fb.onLanding(entity.world, entity.getBlockPos(), state, state, entity); + fb.onLanding(entity.getWorld(), entity.getBlockPos(), state, state, entity); } } } @@ -73,9 +73,9 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER); BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER); - context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block)); + context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY(), entity.getZ(), upperState), block)); - return configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block); + return configure(MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block); } if (block instanceof BlockEntityProvider bep) { @@ -90,10 +90,10 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState state = entity.getBlockState(); if (state.contains(Properties.WATERLOGGED)) { - boolean logged = entity.world.isWater(entity.getBlockPos()); + boolean logged = entity.getWorld().isWater(entity.getBlockPos()); if (state.get(Properties.WATERLOGGED) != logged) { - entity = MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged)); + entity = MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged)); spell.getDisguise().setAppearance(entity); return; } @@ -112,7 +112,7 @@ public class FallingBlockBehaviour extends EntityBehaviour { be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0); } - be.setWorld(entity.world); + be.setWorld(entity.getWorld()); ((Positioned)be).setPos(entity.getBlockPos()); ceb.tick(); be.setWorld(null); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java index 352852aa..86572441 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java @@ -19,16 +19,16 @@ public class GhastBehaviour extends MobBehaviour { if (sneaking) { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.GHAST_WARNS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.GHAST_WARNS, entity.getBlockPos(), 0); } } else { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.GHAST_SHOOTS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.GHAST_SHOOTS, entity.getBlockPos(), 0); } Vec3d rot = player.asEntity().getRotationVec(1); - FireballEntity proj = new FireballEntity(entity.world, player.asEntity(), + FireballEntity proj = new FireballEntity(entity.getWorld(), player.asEntity(), rot.getX(), rot.getY(), rot.getZ(), @@ -40,7 +40,7 @@ public class GhastBehaviour extends MobBehaviour { proj.getZ() + rot.z * 4 ); - entity.world.spawnEntity(proj); + entity.getWorld().spawnEntity(proj); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java index 9a1366e0..52c846ff 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java @@ -11,7 +11,7 @@ public class MinecartBehaviour extends EntityBehaviour { @Override public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); - if (replaceOld && entity.world.isClient) { + if (replaceOld && entity.getWorld().isClient) { InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MINECART, entity.getId()); } return entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java index bdf69f65..a56ae3d9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java @@ -34,7 +34,7 @@ public class MobBehaviour extends EntityBehaviour { @SuppressWarnings("unchecked") protected T getDummy(T entity) { if (dummy == null) { - dummy = (T)entity.getType().create(entity.world); + dummy = (T)entity.getType().create(entity.getWorld()); } return dummy; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java index 86d780d7..d4dbf2e2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java @@ -28,7 +28,7 @@ public class RangedAttackBehaviour extends E if (player.sneakingChanged() && isSneakingOnGround(player)) { - ProjectileEntity spit = projectileSupplier.apply(entity.world, entity); + ProjectileEntity spit = projectileSupplier.apply(entity.getWorld(), entity); Vec3d rot = player.asEntity().getRotationVec(1); @@ -36,10 +36,10 @@ public class RangedAttackBehaviour extends E spit.setOwner(player.asEntity()); if (!entity.isSilent()) { - SoundEmitter.playSoundAt(entity, sound, 1, 1 + (entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F); + SoundEmitter.playSoundAt(entity, sound, 1, 1 + (entity.getWorld().random.nextFloat() - entity.getWorld().random.nextFloat()) * 0.2F); } - entity.world.spawnEntity(spit); + entity.getWorld().spawnEntity(spit); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java index aa027cd7..31715fe0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java @@ -22,17 +22,17 @@ public class SheepBehaviour extends EntityBehaviour { if (player.sneakingChanged()) { BlockPos pos = entity.getBlockPos().down(); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); boolean grass = state.isOf(Blocks.GRASS_BLOCK); if (player.asEntity().isSneaking()) { - if (grass && entity.world.isClient && entity.isSheared()) { + if (grass && entity.getWorld().isClient && entity.isSheared()) { entity.handleStatus((byte)10); } } else { if (entity.isSheared() && grass) { - entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); - entity.world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2); + entity.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); + entity.getWorld().setBlockState(pos, Blocks.DIRT.getDefaultState(), 2); entity.onEatingGrass(); } else if (!entity.isSheared()) { @@ -41,7 +41,7 @@ public class SheepBehaviour extends EntityBehaviour { player.asEntity().playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1, 1); entity.setSheared(true); - Random rng = entity.world.random; + Random rng = entity.getWorld().random; PlayerInventory inv = player.asEntity().getInventory(); int dropAmount = rng.nextInt(3); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java index 47c76ea1..7e298723 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java @@ -24,7 +24,7 @@ public class ShulkerBehaviour extends EntityBehaviour { Direction attachmentFace = shulker.getAttachedFace(); BlockPos pos = shulker.getBlockPos().offset(attachmentFace); - boolean noGravity = !shulker.isOnGround() && !shulker.world.isAir(pos) + boolean noGravity = !shulker.isOnGround() && !shulker.getWorld().isAir(pos) && (attachmentFace == Direction.UP || attachmentFace.getAxis() != Axis.Y); source.asEntity().setNoGravity(noGravity); @@ -54,7 +54,7 @@ public class ShulkerBehaviour extends EntityBehaviour { if (player.sneakingChanged()) { mx.callSetPeekAmount((int)(peekAmount / 0.01F)); } else if (peekAmount > 0.2 && mx.callGetPeekAmount() == 0) { - if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) { + if (shulker.isAlive() && shulker.getWorld().random.nextInt(1000) < shulker.ambientSoundChance++) { shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay(); shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java index 14709927..b6ee8542 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java @@ -14,10 +14,10 @@ public class SilverfishBehaviour extends EntityBehaviour { public void update(Pony player, SilverfishEntity entity, Disguise spell) { if (!player.isClient() && player.sneakingChanged() && player.asEntity().isSneaking()) { BlockPos pos = entity.getBlockPos().down(); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); - if (StateMaps.SILVERFISH_AFFECTED.convert(entity.world, pos)) { - entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); + if (StateMaps.SILVERFISH_AFFECTED.convert(entity.getWorld(), pos)) { + entity.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java index f7720aae..ba89c936 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java @@ -18,7 +18,7 @@ public class SpellcastingIllagerBehaviour extends EntityBehaviour { if (pony.sneakingChanged() && pony.asEntity().isSneaking()) { entity.setHeadRollingTimeLeft(40); - if (!entity.world.isClient()) { + if (!entity.getWorld().isClient()) { entity.playSound(SoundEvents.ENTITY_VILLAGER_NO, 1, 1); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java b/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java index cd5c4f0a..9bad7931 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java @@ -34,7 +34,7 @@ public class EntityCollisions { } else if (entity instanceof FallingBlockEntity) { BlockPos pos = entity.getBlockPos(); output.accept(((FallingBlockEntity) entity).getBlockState() - .getCollisionShape(entity.world, entity.getBlockPos(), context) + .getCollisionShape(entity.getWorld(), entity.getBlockPos(), context) .offset(pos.getX(), pos.getY(), pos.getZ()) ); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java index 3c415da4..9231dfc6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java @@ -25,21 +25,21 @@ public class ButterfingersStatusEffect extends StatusEffect { amplifier = MathHelper.clamp(amplifier, 0, 5); final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900); - if (entity.world.random.nextInt(scale / 4) == 0) { - applyInstantEffect(null, null, entity, amplifier, entity.world.random.nextInt(scale)); + if (entity.getWorld().random.nextInt(scale / 4) == 0) { + applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale)); } } @Override public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { - if (target.world.isClient) { + if (target.getWorld().isClient) { return; } if (target instanceof ServerPlayerEntity player) { if (player.dropSelectedItem(proximity < 1)) { - player.world.playSound(null, player.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, player.getSoundCategory()); + player.getWorld().playSound(null, player.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, player.getSoundCategory()); PlayerInventory inventory = player.getInventory(); player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(-2, 0, inventory.selectedSlot, inventory.getStack(inventory.selectedSlot))); } @@ -48,7 +48,7 @@ public class ButterfingersStatusEffect extends StatusEffect { if (!stack.isEmpty()) { target.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY); target.dropStack(stack); - target.world.playSound(null, target.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, target.getSoundCategory()); + target.getWorld().playSound(null, target.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, target.getSoundCategory()); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java index 908f2303..ebdd1a41 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java @@ -28,35 +28,29 @@ public class CorruptInfluenceStatusEffect extends StatusEffect { @Override public void applyUpdateEffect(LivingEntity entity, int amplifier) { - if (entity.world.isClient) { + if (entity.getWorld().isClient) { return; } if (entity instanceof HostileEntity) { - int nearby = 0; - - for (Entity i : entity.world.getOtherEntities(entity, entity.getBoundingBox().expand(40))) { - if (i.getType() == entity.getType()) { - nearby++; - } - } + int nearby = entity.getWorld().getOtherEntities(entity, entity.getBoundingBox().expand(40), i -> i.getType() == entity.getType()).size(); if (nearby > 1) { if (Equine.of(entity).filter(eq -> eq instanceof Owned o && o.getMaster() != null).isPresent()) { return; } - if (entity.world.random.nextInt(2000) != 0) { + if (entity.getWorld().random.nextInt(2000) != 0) { return; } - } else if (entity.world.random.nextInt(200) != 0) { + } else if (entity.getWorld().random.nextInt(200) != 0) { return; } HostileEntity mob = (HostileEntity)entity; - HostileEntity clone = (HostileEntity)mob.getType().create(mob.world); + HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld()); clone.copyPositionAndRotation(entity); Equine.of(clone).ifPresent(eq -> { @@ -64,10 +58,10 @@ public class CorruptInfluenceStatusEffect extends StatusEffect { ((Owned.Mutable)eq).setMaster(mob); } }); - mob.world.spawnEntity(clone); + mob.getWorld().spawnEntity(clone); if (!mob.isSilent()) { - mob.world.syncWorldEvent((PlayerEntity)null, WorldEvents.ZOMBIE_INFECTS_VILLAGER, mob.getBlockPos(), 0); + mob.getWorld().syncWorldEvent((PlayerEntity)null, WorldEvents.ZOMBIE_INFECTS_VILLAGER, mob.getBlockPos(), 0); } } else if (entity.age % 2000 == 0) { entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java index 7db09496..0ed77c13 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java @@ -80,7 +80,7 @@ public class SunBlindnessStatusEffect extends StatusEffect { return false; } - return isPositionExposedToSun(entity.world, entity.getBlockPos()); + return isPositionExposedToSun(entity.getWorld(), entity.getBlockPos()); } public static boolean isPositionExposedToSun(World world, BlockPos pos) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java b/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java index f74e587d..7ee274d7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java @@ -20,7 +20,7 @@ public interface MeteorlogicalUtil { } // we translate sun angle to a scale of 0-1 (0=sunrise, 1=sunset, >1 nighttime) - final float skyAngle = ((entity.world.getSkyAngle(1) + 0.25F) % 1F) * 2; + final float skyAngle = ((entity.getWorld().getSkyAngle(1) + 0.25F) % 1F) * 2; float playerYaw = MathHelper.wrapDegrees(entity.getHeadYaw()); float playerAngle = (-entity.getPitch(1) / 90F) / 2F; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 7963f14b..f6fa64e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -216,7 +216,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (typeChanged) { pony.spawnParticles(ParticleTypes.CLOUD, 10); - entity.playSound(entity.world.getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); + entity.playSound(entity.getWorld().getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); } entity.getAbilities().allowFlying = type.canFlyCreative(entity); @@ -285,7 +285,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab ticksToGlide = MAX_TICKS_TO_GLIDE; if (!SpellPredicate.IS_DISGUISE.isOn(pony)) { entity.playSound(type.getWingFlapSound(), 0.25F, 1); - entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); + entity.getWorld().emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); } } else { strafe *= 0.28; @@ -345,7 +345,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (type.isAvian()) { applyThrust(velocity); - if (pony.getObservedSpecies() != Race.BAT && entity.world.random.nextInt(9000) == 0) { + if (pony.getObservedSpecies() != Race.BAT && entity.getWorld().random.nextInt(9000) == 0) { entity.dropItem(UItems.PEGASUS_FEATHER); entity.playSound(USounds.ENTITY_PLAYER_PEGASUS_MOLT, 0.3F, 1); UCriteria.SHED_FEATHER.trigger(entity); @@ -355,7 +355,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab moveFlying(velocity); if (type.isAvian()) { - if (entity.world.isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) { + if (entity.getWorld().isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) { flapping = true; ticksToGlide = MAX_TICKS_TO_GLIDE; } @@ -370,7 +370,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab velocity.x *= 0.9896; velocity.z *= 0.9896; } else if (type == FlightType.INSECTOID && !SpellPredicate.IS_DISGUISE.isOn(pony)) { - if (entity.world.isClient && !soundPlaying) { + if (entity.getWorld().isClient && !soundPlaying) { soundPlaying = true; InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ, entity.getId()); } @@ -378,17 +378,17 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } private void tickArtificialFlight(MutableVector velocity) { - if (ticksInAir % 10 == 0 && !entity.world.isClient) { + if (ticksInAir % 10 == 0 && !entity.getWorld().isClient) { ItemStack stack = AmuletItem.getForEntity(entity); int damageInterval = 20; int minDamage = 1; float energyConsumed = 2 + (float)getHorizontalMotion() / 10F; - if (entity.world.hasRain(entity.getBlockPos())) { + if (entity.getWorld().hasRain(entity.getBlockPos())) { energyConsumed *= 3; } - if (entity.world.getDimension().ultrawarm()) { + if (entity.getWorld().getDimension().ultrawarm()) { energyConsumed *= 4; damageInterval /= 2; minDamage *= 3; @@ -400,8 +400,8 @@ public class PlayerPhysics extends EntityPhysics implements Tickab entity.playSound(USounds.ITEM_ICARUS_WINGS_WARN, 0.13F, 0.5F); } - if (entity.world.random.nextInt(damageInterval) == 0) { - stack.damage(minDamage + entity.world.random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); + if (entity.getWorld().random.nextInt(damageInterval) == 0) { + stack.damage(minDamage + entity.getWorld().random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); } if (!getFlightType().canFly()) { @@ -484,9 +484,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickab BlockPos pos = BlockPos.ofFloored(entity.getCameraPosVec(1).add(entity.getRotationVec(1).normalize().multiply(2))); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); - if (!entity.world.isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.world, pos), entity.getHorizontalFacing().getOpposite())) { + if (!entity.getWorld().isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.getWorld(), pos), entity.getHorizontalFacing().getOpposite())) { double motion = Math.sqrt(getHorizontalMotion()); float distance = (float)(motion * 20 - 3); @@ -524,10 +524,10 @@ public class PlayerPhysics extends EntityPhysics implements Tickab velocity.z += forward * MathHelper.cos(entity.getYaw() * 0.017453292F); - if (entity.world.hasRain(entity.getBlockPos())) { + if (entity.getWorld().hasRain(entity.getBlockPos())) { applyTurbulance(velocity); } else { - descentRate -= WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.world) / 3F; + descentRate -= WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.getWorld()) / 3F; } descentRate += 0.001F; @@ -553,7 +553,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab flapping = false; if (!SpellPredicate.IS_DISGUISE.isOn(pony)) { entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1); - entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); + entity.getWorld().emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); } thrustScale = 1; if (manualFlap) { @@ -587,7 +587,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab private void applyTurbulance(MutableVector velocity) { int globalEffectStrength = MathHelper.clamp(entity.getWorld().getGameRules().getInt(UGameRules.WEATHER_EFFECTS_STRENGTH), 0, 100); float effectStrength = Math.min(1, (float)ticksInAir / MAX_TICKS_TO_WEATHER_EFFECTS) * (globalEffectStrength / 100F); - Vec3d gust = WeatherConditions.getGustStrength(entity.world, entity.getBlockPos()).multiply(globalEffectStrength / 100D); + Vec3d gust = WeatherConditions.getGustStrength(entity.getWorld(), entity.getBlockPos()).multiply(globalEffectStrength / 100D); if (effectStrength * gust.getX() >= 1) { SoundEmitter.playSoundAt(entity, USounds.AMBIENT_WIND_GUST, SoundCategory.AMBIENT, 3, 1); @@ -595,7 +595,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab float weight = 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.8F) + (pony.getActualSpecies().canUseEarth() ? 1 : 0); - velocity.add(WeatherConditions.getAirflow(entity.getBlockPos(), entity.world), 0.04F * effectStrength); + velocity.add(WeatherConditions.getAirflow(entity.getBlockPos(), entity.getWorld()), 0.04F * effectStrength); velocity.add(Vec3d.fromPolar( (entity.getPitch() + (float)gust.getY()) * MathHelper.RADIANS_PER_DEGREE, (entity.getYaw() + (float)gust.getZ()) * MathHelper.RADIANS_PER_DEGREE @@ -603,11 +603,11 @@ public class PlayerPhysics extends EntityPhysics implements Tickab effectStrength * (float)gust.getX() / weight ); - if (!entity.world.isClient && effectStrength > 0.9F && entity.world.isThundering() && entity.world.random.nextInt(9000) == 0) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world); + if (!entity.getWorld().isClient && effectStrength > 0.9F && entity.getWorld().isThundering() && entity.getWorld().random.nextInt(9000) == 0) { + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld()); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); - entity.world.spawnEntity(lightning); + entity.getWorld().spawnEntity(lightning); UCriteria.LIGHTNING_STRUCK.trigger(entity); } } @@ -633,19 +633,19 @@ public class PlayerPhysics extends EntityPhysics implements Tickab boolean isEarthPonySmash = pony.getObservedSpecies().canUseEarth() && !isFlying(); int damage = TraceHelper.findBlocks(entity, speed + 4, 1, state -> (isEarthPonySmash && !state.isAir()) || state.isIn(UTags.GLASS_PANES)).stream() .flatMap(pos -> BlockPos.streamOutwards(pos, 2, 2, 2)) - .filter(pos -> (isEarthPonySmash && !entity.world.isAir(pos)) || entity.world.getBlockState(pos).isIn(UTags.GLASS_PANES)) + .filter(pos -> (isEarthPonySmash && !entity.getWorld().isAir(pos)) || entity.getWorld().getBlockState(pos).isIn(UTags.GLASS_PANES)) .reduce(0, (u, pos) -> { if (pony.canModifyAt(pos, ModificationType.PHYSICAL)) { if (isEarthPonySmash) { - BlockDestructionManager.of(entity.world).damageBlock(pos, (int)entity.world.getRandom().nextTriangular(5, 3)); - if (BlockDestructionManager.of(entity.world).getBlockDestruction(pos) >= 9) { - entity.world.breakBlock(pos, true); + BlockDestructionManager.of(entity.getWorld()).damageBlock(pos, (int)entity.getWorld().getRandom().nextTriangular(5, 3)); + if (BlockDestructionManager.of(entity.getWorld()).getBlockDestruction(pos) >= 9) { + entity.getWorld().breakBlock(pos, true); } } else { - entity.world.breakBlock(pos, true); + entity.getWorld().breakBlock(pos, true); } } else { - ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.world, Vec3d.ofCenter(pos), 15); + ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.getWorld(), Vec3d.ofCenter(pos), 15); } return 1; }, Integer::sum); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index ff70e8e0..23e9eb8b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -299,7 +299,7 @@ public class Pony extends Living implements Copyable, Update } public void onSpawn() { - if (entity.world instanceof ServerWorld sw + if (entity.getWorld() instanceof ServerWorld sw && getObservedSpecies() == Race.BAT && sw.getServer().getSaveProperties().getGameMode() != GameMode.ADVENTURE && SunBlindnessStatusEffect.isPositionExposedToSun(sw, getOrigin())) { @@ -434,13 +434,13 @@ public class Pony extends Living implements Copyable, Update private void updateCorruptionDecay() { if (!isClient() && !UItems.ALICORN_AMULET.isApplicable(entity)) { if (entity.age % (10 * ItemTracker.SECONDS) == 0) { - if (entity.world.random.nextInt(100) == 0) { + if (entity.getWorld().random.nextInt(100) == 0) { corruption.add(-1); setDirty(); } if (entity.getHealth() >= entity.getMaxHealth() - 1 && !entity.getHungerManager().isNotFull()) { - corruption.add(-entity.world.random.nextInt(4)); + corruption.add(-entity.getWorld().random.nextInt(4)); setDirty(); } } @@ -608,7 +608,7 @@ public class Pony extends Living implements Copyable, Update } protected void directTakeEnergy(double foodSubtract) { - if (!entity.isCreative() && !entity.world.isClient) { + if (!entity.isCreative() && !entity.getWorld().isClient) { magicExhaustion += ManaConsumptionUtil.consumeMana(mana.getMana(), foodSubtract); } } @@ -707,7 +707,7 @@ public class Pony extends Living implements Copyable, Update boolean forcedSwap = (!alive && entity instanceof ServerPlayerEntity - && entity.world.getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH) + && entity.getWorld().getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH) && oldPlayer.respawnRace.isUnset()) || oldPlayer.getActualSpecies().isUnset(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index 58b6febf..1afa15e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -75,7 +75,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public ParticleEffect getParticleEffect(IItemEntity entity) { - return ((ItemEntity)entity).world.random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; + return ((ItemEntity)entity).getWorld().random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; } @Override @@ -102,14 +102,14 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab public void interactWithPlayer(IItemEntity item, PlayerEntity player) { ItemEntity entity = (ItemEntity)item; - if (!player.world.isClient && !entity.isRemoved() && !player.isCreative()) { + if (!player.getWorld().isClient && !entity.isRemoved() && !player.isCreative()) { if (player.getPos().distanceTo(entity.getPos()) < 0.5) { - if (entity.world.random.nextInt(150) == 0) { + if (entity.getWorld().random.nextInt(150) == 0) { entity.setPickupDelay(0); entity.onPlayerCollision(player); if (player.getMainHandStack().getItem() == this) { - TypedActionResult result = use(player.world, player, Hand.MAIN_HAND); + TypedActionResult result = use(player.getWorld(), player, Hand.MAIN_HAND); if (result.getResult() == ActionResult.SUCCESS) { entity.setPickupDelay(1000); @@ -286,8 +286,8 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab public ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = (ItemEntity)item; - if (entity.world.random.nextInt(500) == 0) { - entity.world.playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); + if (entity.getWorld().random.nextInt(500) == 0) { + entity.getWorld().playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); } return ActionResult.PASS; @@ -295,12 +295,12 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public void inFrameTick(ItemFrameEntity entity) { - Random rng = entity.world.random; + Random rng = entity.getWorld().random; if (rng.nextInt(1500) == 0) { - entity.world.playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); + entity.getWorld().playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); for (int i = 0; i < 5; i++) { - entity.world.addParticle(rng.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME, + entity.getWorld().addParticle(rng.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME, rng.nextTriangular(entity.getX(), 0.5), rng.nextTriangular(entity.getY(), 0.5), rng.nextTriangular(entity.getZ(), 0.5), @@ -310,13 +310,13 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab } if ((entity.age / 1000) % 10 == 0 && entity.age % 50 == 0) { - for (Entity target : VecHelper.findInRange(entity, entity.world, entity.getPos(), 10, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) { + for (Entity target : VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 10, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) { for (ItemStack equipment : target.getItemsEquipped()) { if (equipment.getItem() == UItems.GROGARS_BELL) { ChargeableItem chargeable = (ChargeableItem)UItems.GROGARS_BELL; if (chargeable.hasCharge(equipment)) { ChargeableItem.consumeEnergy(equipment, 3); - ParticleUtils.spawnParticle(entity.world, + ParticleUtils.spawnParticle(entity.getWorld(), new FollowingParticleEffect(UParticles.HEALTH_DRAIN, entity, 0.4F) .withChild(ParticleTypes.COMPOSTER), target.getEyePos(), Vec3d.ZERO); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java index 5c00d94c..e49b3eed 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java @@ -25,32 +25,32 @@ public class AppleItem { private static ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = item.get().asEntity(); - if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) { + if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.getWorld().random.nextInt(150) < 10) { - if (!entity.world.isClient) { + if (!entity.getWorld().isClient) { entity.remove(RemovalReason.KILLED); - ItemEntity neu = EntityType.ITEM.create(entity.world); + ItemEntity neu = EntityType.ITEM.create(entity.getWorld()); neu.copyPositionAndRotation(entity); neu.setStack(new ItemStack(UItems.ROTTEN_APPLE)); - entity.world.spawnEntity(neu); + entity.getWorld().spawnEntity(neu); - ItemEntity copy = EntityType.ITEM.create(entity.world); + ItemEntity copy = EntityType.ITEM.create(entity.getWorld()); copy.copyPositionAndRotation(entity); copy.setStack(entity.getStack()); copy.getStack().decrement(1); - entity.world.spawnEntity(copy); + entity.getWorld().spawnEntity(copy); } float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.uniqueOffset) * 0.1F + 0.1F; for (int i = 0; i < 3; i++) { - entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F); + entity.getWorld().addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), + entity.getWorld().random.nextGaussian() - 0.5F, + entity.getWorld().random.nextGaussian() - 0.5F, + entity.getWorld().random.nextGaussian() - 0.5F); } entity.playSound(USounds.ITEM_APPLE_ROT, 0.5F, 1.5F); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java index b3ed6200..314df0ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java @@ -106,18 +106,18 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art entity.addSpin(2, 10); BlockPos pos = entity.getBlockPos(); - entity.world.addParticle(ParticleTypes.COMPOSTER, - pos.getX() + entity.world.getRandom().nextFloat(), - pos.getY() + entity.world.getRandom().nextFloat(), - pos.getZ() + entity.world.getRandom().nextFloat(), + entity.getWorld().addParticle(ParticleTypes.COMPOSTER, + pos.getX() + entity.getWorld().getRandom().nextFloat(), + pos.getY() + entity.getWorld().getRandom().nextFloat(), + pos.getZ() + entity.getWorld().getRandom().nextFloat(), 0, 0, 0); - if (entity.world.getTime() % 80 == 0 && !entity.world.isClient) { + if (entity.getWorld().getTime() % 80 == 0 && !entity.getWorld().isClient) { List inputs = new ArrayList<>(); List outputs = new ArrayList<>(); List containers = new ArrayList<>(); - VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, TARGET_PREDICATE).forEach(e -> { + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 20, TARGET_PREDICATE).forEach(e -> { LivingEntity living = (LivingEntity)e; if (e instanceof PlayerEntity @@ -130,7 +130,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art inputs.add(living); } }); - VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, i -> { + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 20, i -> { return i instanceof ItemEntity ie && isFillable(ie.getStack()) && Equine.of(i).filter(p -> p.getSpecies() == Race.CHANGELING).isPresent(); }).forEach(i -> containers.add((ItemEntity)i)); @@ -177,7 +177,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art @Override public ActionResult onArtifactDestroyed(FloatingArtefactEntity entity) { entity.playSound(USounds.ENTITY_CRYSTAL_HEART_DEACTIVATE, 0.75F, 1); - entity.dropStack(new ItemStack(UItems.CRYSTAL_SHARD, 1 + entity.world.random.nextInt(5)), 0); + entity.dropStack(new ItemStack(UItems.CRYSTAL_SHARD, 1 + entity.getWorld().random.nextInt(5)), 0); return ActionResult.SUCCESS; } @@ -188,13 +188,13 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art private boolean findPyramid(FloatingArtefactEntity entity, Direction direction) { BlockPos tip = entity.getBlockPos().offset(direction); - BlockState tipState = entity.world.getBlockState(tip); + BlockState tipState = entity.getWorld().getBlockState(tip); if (!tipState.isIn(UTags.CRYSTAL_HEART_ORNAMENT) || (!tipState.contains(EndRodBlock.FACING)|| tipState.get(EndRodBlock.FACING) != direction.getOpposite())) { return false; } tip = tip.offset(direction); - if (!isDiamond(entity.world.getBlockState(tip))) { + if (!isDiamond(entity.getWorld().getBlockState(tip))) { return false; } tip = tip.offset(direction); @@ -203,7 +203,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art return BlockPos.streamOutwards(center, 1, 0, 1) .filter(p -> p.getX() == center.getX() || p.getZ() == center.getZ()) - .map(entity.world::getBlockState) + .map(entity.getWorld()::getBlockState) .allMatch(this::isDiamond); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java b/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java index 6ac2b43b..39d8598d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java @@ -45,7 +45,7 @@ public interface EnchantableItem extends ItemConvertible { return TypedActionResult.fail(SpellType.EMPTY_KEY.withTraits()); } - if (!player.world.isClient && consume) { + if (!player.getWorld().isClient && consume) { player.swingHand(player.getStackInHand(Hand.OFF_HAND) == stack ? Hand.OFF_HAND : Hand.MAIN_HAND); player.getItemCooldownManager().set(stack.getItem(), 20); diff --git a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java index b2aeef6d..6a5b9c08 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java @@ -106,8 +106,8 @@ public class FilledJarItem extends JarItem implements ChameleonItem { float healthDiff = prevHealth - ((LivingEntity)entity).getHealth(); - if (projectile.world instanceof ServerWorld && healthDiff > 2) { - ((ServerWorld)projectile.world).spawnParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getBodyY(0.5D), entity.getZ(), (int)(healthDiff / 2F), 0.1, 0, 0.1, 0.2); + if (projectile.getWorld() instanceof ServerWorld && healthDiff > 2) { + ((ServerWorld)projectile.getWorld()).spawnParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getBodyY(0.5D), entity.getZ(), (int)(healthDiff / 2F), 0.1, 0, 0.1, 0.2); } } else { entity.addVelocity( @@ -125,9 +125,9 @@ public class FilledJarItem extends JarItem implements ChameleonItem { @Override public void onImpact(MagicProjectileEntity projectile) { ItemStack stack = getAppearanceStack(projectile.getStack()); - stack.damage(1, projectile.world.random, null); + stack.damage(1, projectile.getWorld().random, null); projectile.dropStack(stack); - projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); + projectile.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); } public ItemStack withContents(ItemStack contents) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java index 5ff0cde5..663dd8a5 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.RecipeSerializer; @@ -16,7 +16,7 @@ public class GlowingRecipe extends ItemCombinationRecipe { } @Override - public final ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public final ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { Pair pair = runMatch(inventory); ItemStack result = pair.getLeft().copy(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java index 62c91309..ccdaa038 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.book.CraftingRecipeCategory; @@ -20,13 +20,13 @@ public abstract class ItemCombinationRecipe extends SpecialCraftingRecipe { } @Override - public final boolean matches(CraftingInventory inventory, World world) { + public final boolean matches(RecipeInputInventory inventory, World world) { Pair result = runMatch(inventory); return !result.getLeft().isEmpty() && !result.getRight().isEmpty(); } - protected Pair runMatch(CraftingInventory inventory) { + protected Pair runMatch(RecipeInputInventory inventory) { ItemStack bangle = ItemStack.EMPTY; ItemStack dust = ItemStack.EMPTY; diff --git a/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java index 0bce42f5..73a68e55 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.book.CraftingRecipeCategory; @@ -15,7 +15,7 @@ public class JarInsertRecipe extends ItemCombinationRecipe { } @Override - public final ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public final ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { Pair pair = runMatch(inventory); return UItems.FILLED_JAR.setAppearance(UItems.FILLED_JAR.getDefaultStack(), pair.getRight()); diff --git a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java index 338c0b6a..809576a2 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java @@ -44,32 +44,32 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba entity.setInvulnerable(true); if (!lightning - && !entity.world.isClient + && !entity.getWorld().isClient && !entity.isRemoved() && entity.getItemAge() > 100 - && entity.world.isThundering() - && entity.world.isSkyVisible(entity.getBlockPos()) - && entity.world.random.nextInt(130) == 0) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world); + && entity.getWorld().isThundering() + && entity.getWorld().isSkyVisible(entity.getBlockPos()) + && entity.getWorld().random.nextInt(130) == 0) { + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld()); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); entity.remove(RemovalReason.DISCARDED); - entity.world.spawnEntity(lightning); + entity.getWorld().spawnEntity(lightning); - ItemEntity neu = EntityType.ITEM.create(entity.world); + ItemEntity neu = EntityType.ITEM.create(entity.getWorld()); neu.copyPositionAndRotation(entity); neu.setStack(new ItemStack(this == UItems.RAIN_CLOUD_JAR ? UItems.STORM_CLOUD_JAR : UItems.LIGHTNING_JAR)); neu.setInvulnerable(true); - entity.world.spawnEntity(neu); + entity.getWorld().spawnEntity(neu); - ItemEntity copy = EntityType.ITEM.create(entity.world); + ItemEntity copy = EntityType.ITEM.create(entity.getWorld()); copy.copyPositionAndRotation(entity); copy.setInvulnerable(true); copy.setStack(entity.getStack()); copy.getStack().decrement(1); - entity.world.spawnEntity(copy); + entity.getWorld().spawnEntity(copy); } return ActionResult.PASS; } @@ -81,8 +81,8 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba @Override public void onImpact(MagicProjectileEntity projectile) { - if (!projectile.world.isClient()) { - ServerWorld world = (ServerWorld)projectile.world; + if (!projectile.getWorld().isClient()) { + ServerWorld world = (ServerWorld)projectile.getWorld(); if (rain || thunder) { // clear weather time = number of ticks for which the weather is clear @@ -128,22 +128,22 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba } if (lightning) { - ParticleUtils.spawnParticle(projectile.world, UParticles.LIGHTNING_BOLT, projectile.getPos(), Vec3d.ZERO); + ParticleUtils.spawnParticle(projectile.getWorld(), UParticles.LIGHTNING_BOLT, projectile.getPos(), Vec3d.ZERO); } if (rain || thunder) { - projectile.world.syncWorldEvent(WorldEvents.SPLASH_POTION_SPLASHED, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8); + projectile.getWorld().syncWorldEvent(WorldEvents.SPLASH_POTION_SPLASHED, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8); - for (int i = projectile.world.random.nextInt(3) + 1; i >= 0; i--) { - ParticleUtils.spawnParticle(projectile.world, UParticles.CLOUDS_ESCAPING, + for (int i = projectile.getWorld().random.nextInt(3) + 1; i >= 0; i--) { + ParticleUtils.spawnParticle(projectile.getWorld(), UParticles.CLOUDS_ESCAPING, projectile.getX(), projectile.getY(), projectile.getZ(), - projectile.world.random.nextFloat() - 0.5, + projectile.getWorld().random.nextFloat() - 0.5, 0, - projectile.world.random.nextFloat() - 0.5 + projectile.getWorld().random.nextFloat() - 0.5 ); } } - projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); + projectile.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java index adbf5474..65cdb292 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java @@ -32,8 +32,8 @@ public class PegasusAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { - if (entity.world.getTime() % 6 == 0 && entity instanceof LivingEntity living && isApplicable(living)) { - ParticleUtils.spawnParticles(entity.world.getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); + if (entity.getWorld().getTime() % 6 == 0 && entity instanceof LivingEntity living && isApplicable(living)) { + ParticleUtils.spawnParticles(entity.getWorld().getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java b/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java index 14360d98..d9bca4b7 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java @@ -23,7 +23,7 @@ public class PineappleItem extends Item { user.eatFood(world, stack.copy()); if (!world.isClient) { stack.damage(1, user, u -> { - AwaitTickQueue.scheduleTask(u.world, w -> { + AwaitTickQueue.scheduleTask(u.getWorld(), w -> { w.playSoundFromEntity(null, u, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 1, 0.7F); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java index 07f46a74..a9febf20 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java @@ -47,9 +47,9 @@ public class StaffItem extends SwordItem { for (int i = 0; i < 130; i++) { w.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.OAK_LOG.getDefaultState()), - target.getX() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), - (target.getY() + dims.height / 2) + (target.world.random.nextFloat() - 0.5F) * dims.height, - target.getZ() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), + target.getX() + (target.getWorld().random.nextFloat() - 0.5F) * (dims.width + 1), + (target.getY() + dims.height / 2) + (target.getWorld().random.nextFloat() - 0.5F) * dims.height, + target.getZ() + (target.getWorld().random.nextFloat() - 0.5F) * (dims.width + 1), 0, 0, 0 ); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index f2f5623c..70d07536 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -20,6 +20,7 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.Registries; public interface UItems { @@ -137,7 +138,7 @@ public interface UItems { Item BAT_BADGE = register(Race.BAT); Item CHANGELING_BADGE = register(Race.CHANGELING); - static T register(String name, T item, ItemGroup group) { + static T register(String name, T item, RegistryKey group) { return ItemGroupRegistry.register(register(name, item), group); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java index 21ef9f4c..a3d13d6e 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java @@ -47,7 +47,7 @@ public interface URecipes { } Identifier modId = new Identifier("unicopiamc", id.getPath()); - LootTable table = manager.getTable(modId); + LootTable table = manager.getLootTable(modId); if (table != LootTable.EMPTY) { supplier.pools(List.of(table.pools)); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java index 883d6ad2..438769db 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java @@ -80,18 +80,18 @@ public class ZapAppleItem extends Item implements ChameleonItem, ToxicHolder, Mu public TypedActionResult onFedTo(ItemStack stack, PlayerEntity player, Entity e) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.world); + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.getWorld()); lightning.refreshPositionAfterTeleport(e.getX(), e.getY(), e.getZ()); lightning.setCosmetic(true); if (player instanceof ServerPlayerEntity) { lightning.setChanneler((ServerPlayerEntity)player); } - if (e.world instanceof ServerWorld) { - e.onStruckByLightning((ServerWorld)e.world, lightning); + if (!e.getWorld().isClient) { + e.onStruckByLightning((ServerWorld)e.getWorld(), lightning); UCriteria.FEED_TRICK_APPLE.trigger(player); } - player.world.spawnEntity(lightning); + player.getWorld().spawnEntity(lightning); if (!player.getAbilities().creativeMode) { stack.decrement(1); diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java index 0dcadd0d..c82ff3bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java @@ -11,10 +11,13 @@ import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.item.*; import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; public interface ItemGroupRegistry { - Map> REGISTRY = new HashMap<>(); + Map, Set> REGISTRY = new HashMap<>(); static List getVariations(Item item) { if (item instanceof MultiItem) { @@ -23,20 +26,22 @@ public interface ItemGroupRegistry { return List.of(item.getDefaultStack()); } - static T register(T item, ItemGroup group) { + static T register(T item, RegistryKey group) { REGISTRY.computeIfAbsent(group, g -> new LinkedHashSet<>()).add(item); return item; } - static ItemGroup createDynamic(String name, Supplier icon, Supplier> items) { - return FabricItemGroup.builder(Unicopia.id(name)).entries((context, entries) -> { + static RegistryKey createDynamic(String name, Supplier icon, Supplier> items) { + RegistryKey key = RegistryKey.of(RegistryKeys.ITEM_GROUP, Unicopia.id(name)); + Registry.register(Registries.ITEM_GROUP, key.getValue(), FabricItemGroup.builder().entries((context, entries) -> { items.get().forEach(item -> { entries.addAll(ItemGroupRegistry.getVariations(item)); }); - }).icon(icon).build(); + }).icon(icon).build()); + return key; } - static ItemGroup createGroupFromTag(String name, Supplier icon) { + static RegistryKey createGroupFromTag(String name, Supplier icon) { TagKey key = UTags.item("groups/" + name); return createDynamic(name, icon, () -> { return Registries.ITEM.getEntryList(key) diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java index 26fe630d..080a07b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java @@ -9,22 +9,23 @@ import com.minelittlepony.unicopia.item.toxin.ToxicHolder; import net.minecraft.item.*; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; public interface UItemGroups { - ItemGroup ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> { + RegistryKey ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> { return Stream.concat(Stream.of(Items.APPLE), UItems.ITEMS.stream() .filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised())); }); - ItemGroup HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> { + RegistryKey HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> { return Registries.ITEM.stream() .filter(item -> ((ToxicHolder)item).getToxic(item.getDefaultStack()) != Toxic.EMPTY); }); - ItemGroup EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.EARTH_BADGE::getDefaultStack); - ItemGroup UNICORN_ITEMS = ItemGroupRegistry.createGroupFromTag("unicorn", UItems.UNICORN_BADGE::getDefaultStack); - ItemGroup PEGASUS_ITEMS = ItemGroupRegistry.createGroupFromTag("pegasus", UItems.PEGASUS_BADGE::getDefaultStack); - ItemGroup BAT_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("bat_pony", UItems.BAT_BADGE::getDefaultStack); - ItemGroup CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.CHANGELING_BADGE::getDefaultStack); + RegistryKey EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.EARTH_BADGE::getDefaultStack); + RegistryKey UNICORN_ITEMS = ItemGroupRegistry.createGroupFromTag("unicorn", UItems.UNICORN_BADGE::getDefaultStack); + RegistryKey PEGASUS_ITEMS = ItemGroupRegistry.createGroupFromTag("pegasus", UItems.PEGASUS_BADGE::getDefaultStack); + RegistryKey BAT_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("bat_pony", UItems.BAT_BADGE::getDefaultStack); + RegistryKey CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.CHANGELING_BADGE::getDefaultStack); static void bootstrap() { ItemGroupRegistry.bootstrap(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java index d5ecaeda..2b054e88 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.Difficulty; public interface Toxin extends Affliction { - Predicate IF_NOT_PEACEFUL = Predicate.of(Text.of("when not in peaceful "), (player, stack) -> player.world.getDifficulty() != Difficulty.PEACEFUL); + Predicate IF_NOT_PEACEFUL = Predicate.of(Text.of("when not in peaceful "), (player, stack) -> player.getWorld().getDifficulty() != Difficulty.PEACEFUL); Toxin INNERT = of(Text.of("No Effect"), (player, stack) -> {}); @@ -45,7 +45,7 @@ public interface Toxin extends Affliction { Toxin LOVE_CONSUMPTION = of(Text.literal("Love"), (player, stack) -> { player.heal(stack.isFood() ? stack.getItem().getFoodComponent().getHunger() : 1); player.removeStatusEffect(StatusEffects.NAUSEA); - if (player.world.random.nextInt(10) == 0) { + if (player.getWorld().random.nextInt(10) == 0) { player.removeStatusEffect(UEffects.FOOD_POISONING); } }); @@ -59,7 +59,7 @@ public interface Toxin extends Affliction { } default Toxin withChance(int max) { - return Predicate.of(Text.of("1 in " + max + " chance of "), (player, stack) -> player.world.random.nextInt(max) == 0).then(this); + return Predicate.of(Text.of("1 in " + max + " chance of "), (player, stack) -> player.getWorld().random.nextInt(max) == 0).then(this); } Text getName(); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java index 931de7f8..e6cbed71 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java @@ -168,7 +168,7 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ activeItemStack = stack; itemUseTimeLeft = time; - if (!world.isClient) { + if (!getWorld().isClient) { setLivingFlag(1, !stack.isEmpty()); setLivingFlag(2, hand == Hand.OFF_HAND); } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java index 6d5ef789..d836f0fc 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java @@ -36,13 +36,13 @@ abstract class MixinMobEntity extends LivingEntity implements Equine.Container> info) { - if (!world.isClient) { + if (!getWorld().isClient) { get().trySleep(pos).ifPresent(reason -> { ((PlayerEntity)(Object)this).sendMessage(reason, true); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java index 9d012156..5debbac8 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java @@ -41,7 +41,7 @@ abstract class MixinPlayerInventory implements Inventory, Nameable { for (int i = 0; i < original.size(); i++) { ItemStack stack = original.get(i); if (EnchantmentHelper.getLevel(Enchantments.BINDING_CURSE, stack) == 0 - && EnchantmentUtil.consumeEnchantment(UEnchantments.HEART_BOUND, 1, stack, player.world.random, EnchantmentUtil.getLuck(3, player))) { + && EnchantmentUtil.consumeEnchantment(UEnchantments.HEART_BOUND, 1, stack, player.getWorld().random, EnchantmentUtil.getLuck(3, player))) { original.set(i, ItemStack.EMPTY); UCriteria.USE_SOULMATE.trigger(player); storedCombinedInventory.get(group).set(i, stack); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java index 2c567e7f..9ec1f042 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java @@ -26,7 +26,7 @@ abstract class MixinServerPlayNetworkHandler implements EntityTrackingListener, @Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD")) private void beforePlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) { ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player; - NetworkThreadUtils.forceMainThread(packet, this, player.getWorld()); + NetworkThreadUtils.forceMainThread(packet, this, player.getServerWorld()); flyingSurvival = Pony.of(player).getPhysics().isFlyingSurvival; if (flyingSurvival) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java index d6fd67a5..58faae77 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java @@ -9,15 +9,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.entity.effect.RaceChangeStatusEffect; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; @Mixin(InGameHud.class) abstract class MixinInGameHud { - @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V", at = @At("HEAD")) - private void onRender(MatrixStack stack, float tickDelta, CallbackInfo info) { - UHud.INSTANCE.render((InGameHud)(Object)this, stack, tickDelta); + @Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("HEAD")) + private void onRender(DrawContext context, float tickDelta, CallbackInfo info) { + UHud.INSTANCE.render((InGameHud)(Object)this, context, tickDelta); } } diff --git a/src/main/java/com/minelittlepony/unicopia/network/Channel.java b/src/main/java/com/minelittlepony/unicopia/network/Channel.java index ecec7f6a..5e6f08cc 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/Channel.java +++ b/src/main/java/com/minelittlepony/unicopia/network/Channel.java @@ -35,7 +35,7 @@ public interface Channel { ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { Pony pony = Pony.of(handler.player); if (pony.getActualSpecies() == Race.UNSET) { - Race race = WorldTribeManager.forWorld(handler.player.getWorld()).getDefaultRace(); + Race race = WorldTribeManager.forWorld(handler.player.getServerWorld()).getDefaultRace(); if (!race.isPermitted(handler.player)) { race = Race.UNSET; } diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java index d5e702fa..cbed2041 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java @@ -39,11 +39,11 @@ public record MsgRequestSpeciesChange ( player.setSpecies(newRace.isPermitted(sender) ? newRace : WorldTribeManager.forWorld((ServerWorld)player.asWorld()).getDefaultRace()); if (force) { - if (sender.world.getGameRules().getBoolean(UGameRules.ANNOUNCE_TRIBE_JOINS)) { + if (sender.getWorld().getGameRules().getBoolean(UGameRules.ANNOUNCE_TRIBE_JOINS)) { Text message = Text.translatable("respawn.reason.joined_new_tribe", sender.getDisplayName(), player.getActualSpecies().getDisplayName(), player.getActualSpecies().getAltDisplayName()); - sender.world.getPlayers().forEach(p -> { + sender.getWorld().getPlayers().forEach(p -> { ((ServerPlayerEntity)p).sendMessageToClient(message, false); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java b/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java index fd85b6bb..34a90ed9 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java @@ -17,6 +17,10 @@ public record MsgSpellbookStateChanged ( SpellbookState state ) implements HandledPacket { + public static MsgSpellbookStateChanged create(SpellbookScreenHandler handler, SpellbookState state) { + return new MsgSpellbookStateChanged<>(handler.syncId, state); + } + public MsgSpellbookStateChanged(PacketByteBuf buffer) { this(buffer.readInt(), new SpellbookState().fromPacket(buffer)); } diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java index a7a4eb5d..fa190703 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java @@ -28,7 +28,7 @@ public class ParticleHandle { public Optional update(UUID id, String partName, ParticleSource source, Consumer constructor) { return get(partName).or(() -> { - if (source.asEntity().world.isClient) { + if (source.asEntity().getWorld().isClient) { new ClientHandle().addParticle(id, partName, source, constructor); } return get(partName); diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java index f851f53e..27a7caff 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java @@ -20,7 +20,7 @@ public interface ParticleUtils { } static void spawnParticles(ParticleEffect effect, Entity entity, int count) { - spawnParticles(entity.world, getShapeFor(entity), effect, count); + spawnParticles(entity.getWorld(), getShapeFor(entity), effect, count); } static void spawnParticles(ParticleEffect effect, World world, Vec3d origin, int count) { diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index cd831019..d32d308a 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -168,7 +168,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster 90) { discard(); } @@ -183,7 +183,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster spell.tick(this, Situation.PROJECTILE)); if (getHydrophobic()) { - if (world.getBlockState(getBlockPos()).getMaterial().isLiquid()) { + if (getWorld().getBlockState(getBlockPos()).isLiquid()) { Vec3d vel = getVelocity(); double velY = vel.y; @@ -198,7 +198,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster { + homingTarget.ifPresent(getWorld(), e -> { setNoGravity(true); noClip = true; setVelocity(getVelocity().add(e.getPos().subtract(getPos()).normalize().multiply(0.2)).multiply(0.6, 0.6, 0.6)); @@ -225,7 +225,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster { Optional.ofNullable(predicate.apply(spell)).ifPresent(consumer); return Operation.SKIP; - }, world.isClient); + }, getWorld().isClient); Optional.ofNullable(predicate.apply(getItem().getItem())).ifPresent(consumer); } diff --git a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java index 6dc96b19..ade56cb9 100644 --- a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java +++ b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java @@ -57,7 +57,7 @@ public class UnicopiaTrinket implements Trinket { @Override public void tick(ItemStack stack, SlotReference slot, LivingEntity entity) { - item.inventoryTick(stack, entity.world, entity, slot.index(), false); + item.inventoryTick(stack, entity.getWorld(), entity, slot.index(), false); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java b/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java index b9cd1b0e..033898ad 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java +++ b/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java @@ -18,7 +18,7 @@ public interface SoundEmitter extends EntityConvertable { } default float getRandomPitch() { - return getRandomPitch(asEntity().world.getRandom()); + return getRandomPitch(asEntity().getWorld().getRandom()); } static void playSoundAt(Entity entity, SoundEvent sound, float volume, float pitch) { @@ -26,7 +26,7 @@ public interface SoundEmitter extends EntityConvertable { } static void playSoundAt(Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch) { - entity.world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, category, volume, pitch); + entity.getWorld().playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, category, volume, pitch); } static float getRandomPitch(Random rng) { diff --git a/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java b/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java index e8a2ddca..f5b6f3df 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java +++ b/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java @@ -66,7 +66,7 @@ public class TraceHelper { final Vec3d start = e.getCameraPosVec(tickDelta); return BlockView.raycast(start, start.add(orientation.multiply(distance)), new ArrayList(), (ctx, pos) -> { - if (predicate.test(e.world.getBlockState(pos))) { + if (predicate.test(e.getWorld().getBlockState(pos))) { ctx.add(pos); } return null;