diff --git a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java index 6ba7b8fa..d2b8f3d6 100644 --- a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java +++ b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java @@ -1,54 +1,31 @@ package com.minelittlepony.unicopia; -import com.google.common.base.Predicate; -import com.minelittlepony.unicopia.entity.Ponylike; -import com.minelittlepony.unicopia.entity.player.Pony; +import java.util.function.Predicate; +import com.minelittlepony.unicopia.entity.CloudEntity; +import com.minelittlepony.unicopia.entity.Ponylike; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; public interface EquinePredicates { - Predicate INTERACT_WITH_CLOUDS = player -> { - return player != null && Pony.of(player).getSpecies().canInteractWithClouds(); - }; + Predicate IS_CLOUD = e -> e instanceof CloudEntity; + Predicate IS_PLAYER = e -> e instanceof PlayerEntity; + Predicate IS_VALID_ITEM = entity -> entity instanceof ItemEntity && entity.isAlive() && entity.age > 1; - Predicate MAGI = entity -> { - return entity instanceof PlayerEntity && Pony.of((PlayerEntity)entity).getSpecies().canCast(); - }; + Predicate RACE_INTERACT_WITH_CLOUDS = entity -> Ponylike.of(entity).getSpecies().canInteractWithClouds(); - Predicate ITEMS = entity -> { - return entity instanceof ItemEntity && entity.isAlive() && entity.age > 1; - }; + Predicate PLAYER_UNICORN = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies().canCast()); + Predicate PLAYER_CHANGELING = IS_PLAYER.and(entity -> Ponylike.of(entity).getSpecies() == Race.CHANGELING); + Predicate PLAYER_PEGASUS = IS_PLAYER.and(entity -> ((PlayerEntity)entity).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(entity)); - Predicate ITEM_INTERACT_WITH_CLOUDS = item -> { - return ITEMS.test(item) && Ponylike.of(item).getSpecies().canInteractWithClouds(); - }; + Predicate ITEM_INTERACT_WITH_CLOUDS = IS_VALID_ITEM.and(RACE_INTERACT_WITH_CLOUDS); - Predicate ENTITY_INTERACT_WITH_CLOUDS = entity -> { - return entity != null && ( - (entity instanceof PlayerEntity && INTERACT_WITH_CLOUDS.test((PlayerEntity)entity)) - || (entity instanceof ItemEntity && ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)entity)) - ); - }; + Predicate ENTITY_INTERACT_WITH_CLOUDS = PLAYER_PEGASUS.or(ITEM_INTERACT_WITH_CLOUDS); + Predicate ENTITY_WALK_ON_CLOUDS = entity -> entity instanceof LivingEntity && CloudEntity.getFeatherEnchantStrength((LivingEntity)entity) > 0; - Predicate BUGGY = entity -> { - return entity instanceof PlayerEntity - && Pony.of((PlayerEntity)entity).getSpecies() == Race.CHANGELING; - }; - - static PlayerEntity getPlayerFromEntity(Entity entity) { - if (entity instanceof PlayerEntity) { - return (PlayerEntity) entity; - } - - if (entity instanceof ItemEntity) { - ItemEntity item = (ItemEntity)entity; - if (item.getOwner() != null) { - return item.getEntityWorld().getPlayerByUuid(item.getOwner()); - } - } - - return null; - } + Predicate ENTITY_INTERACT_WITH_CLOUD_BLOCKS = IS_CLOUD.or(PLAYER_PEGASUS).or(ENTITY_WALK_ON_CLOUDS).or(ITEM_INTERACT_WITH_CLOUDS).or(entity -> { + return entity != null && EquinePredicates.ENTITY_INTERACT_WITH_CLOUD_BLOCKS.test(entity.getVehicle()); + }); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/DiamondDoorBlock.java b/src/main/java/com/minelittlepony/unicopia/block/DiamondDoorBlock.java index 25f1c4b9..092022db 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/DiamondDoorBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/DiamondDoorBlock.java @@ -24,7 +24,7 @@ public class DiamondDoorBlock extends AbstractDoorBlock { @Override protected boolean canOpen(@Nullable PlayerEntity player) { - return EquinePredicates.MAGI.test(player); + return EquinePredicates.PLAYER_UNICORN.test(player); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java index 703b9005..09784e86 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SlimeDropBlock.java @@ -170,7 +170,7 @@ public class SlimeDropBlock extends Block implements Climbable { if (entity instanceof LivingEntity && !entity.removed) { LivingEntity living = (LivingEntity)entity; - if (!EquinePredicates.BUGGY.test(living) && living.getHealth() > 0) { + if (!EquinePredicates.PLAYER_CHANGELING.test(living) && living.getHealth() > 0) { living.damage(MagicalDamageSource.ACID, 1); living.slowMovement(state, new Vec3d(0.25D, 0.05000000074505806D, 0.25D)); diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index d3125f52..1ac18198 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.client; -import static com.minelittlepony.unicopia.EquinePredicates.MAGI; +import static com.minelittlepony.unicopia.EquinePredicates.PLAYER_UNICORN; import javax.annotation.Nullable; @@ -54,7 +54,7 @@ public class UnicopiaClient implements ClientModInitializer { }, UItems.APPLE_LEAVES); ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.APPLE_LEAVES); ColorProviderRegistry.ITEM.register((stack, tint) -> { - if (MAGI.test(MinecraftClient.getInstance().player)) { + if (PLAYER_UNICORN.test(MinecraftClient.getInstance().player)) { return SpellRegistry.instance().getSpellTintFromStack(stack); } return 0xFFFFFF; diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java b/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java index 1d851113..87547314 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellBookContainer.java @@ -157,7 +157,7 @@ public class SpellBookContainer extends Container { @Override public boolean canUse(PlayerEntity player) { - return EquinePredicates.MAGI.test(player); + return EquinePredicates.PLAYER_UNICORN.test(player); } public static class SpellbookSlot extends Slot { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java index 8c922140..80ed424a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java @@ -28,6 +28,7 @@ import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LightningEntity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; import net.minecraft.entity.SpawnType; import net.minecraft.entity.damage.DamageSource; @@ -154,7 +155,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate @Override public void pushAwayFrom(Entity other) { if (other instanceof PlayerEntity) { - if (EquinePredicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)other)) { + if (EquinePredicates.PLAYER_PEGASUS.test(other)) { super.pushAwayFrom(other); } } else if (other instanceof CloudEntity) { @@ -429,7 +430,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate ItemStack stack = player.getMainHandStack(); boolean canFly = EnchantmentHelper.getEnchantments(stack).containsKey(Enchantments.FEATHER_FALLING) - || EquinePredicates.INTERACT_WITH_CLOUDS.test(player); + || EquinePredicates.PLAYER_PEGASUS.test(player); boolean stat = getStationary(); if (stat || canFly) { @@ -479,7 +480,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate private boolean entityIsFloatingItem(Entity e) { return e instanceof ItemEntity - && EquinePredicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)e); + && EquinePredicates.ITEM_INTERACT_WITH_CLOUDS.test(e); } @Override @@ -575,15 +576,15 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate return 3; } - if (entity instanceof PlayerEntity) { - return getFeatherEnchantStrength((PlayerEntity)entity); + if (entity instanceof LivingEntity) { + return getFeatherEnchantStrength((LivingEntity)entity); } return 0; } - public static int getFeatherEnchantStrength(PlayerEntity player) { - for (ItemStack stack : player.getArmorItems()) { + public static int getFeatherEnchantStrength(LivingEntity entity) { + for (ItemStack stack : entity.getArmorItems()) { if (stack != null) { Map enchantments = EnchantmentHelper.getEnchantments(stack); if (enchantments.containsKey(Enchantments.FEATHER_FALLING)) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java index 438beb3f..e2a0b2da 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java @@ -39,7 +39,7 @@ public class ConstructionCloudEntity extends CloudEntity { @Override public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) { if (!(hasPassengers() || isConnectedThroughVehicle(player)) && hand == Hand.MAIN_HAND) { - if (EquinePredicates.INTERACT_WITH_CLOUDS.test(player)) { + if (EquinePredicates.PLAYER_PEGASUS.test(player)) { if (player.getItemUseTime() > 0) { return ActionResult.FAIL; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java index 063d039a..c0bf9bb0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java @@ -80,7 +80,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate @Override public boolean damage(DamageSource source, float amount) { - if (EquinePredicates.BUGGY.test(source.getSource())) { + if (EquinePredicates.PLAYER_CHANGELING.test(source.getSource())) { amount = 0; } @@ -93,7 +93,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate && !entity.isSneaking() && !hasPassengers() && entity instanceof LivingEntity - && !EquinePredicates.BUGGY.test(entity); + && !EquinePredicates.PLAYER_CHANGELING.test(entity); } @Override @@ -149,7 +149,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate @Override public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) { - if (hand == Hand.MAIN_HAND && EquinePredicates.BUGGY.test(player)) { + if (hand == Hand.MAIN_HAND && EquinePredicates.PLAYER_CHANGELING.test(player)) { if (hasPassengers()) { Entity passenger = getPrimaryPassenger(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java index d7687362..488528ad 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/RacingCloudEntity.java @@ -42,7 +42,7 @@ public class RacingCloudEntity extends CloudEntity { @Override public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) { if (!(hasPassengers() || isConnectedThroughVehicle(player)) && hand == Hand.MAIN_HAND) { - if (EquinePredicates.INTERACT_WITH_CLOUDS.test(player)) { + if (EquinePredicates.PLAYER_PEGASUS.test(player)) { if (!getStationary()) { player.startRiding(this); return ActionResult.SUCCESS; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java index e20c2ca4..8954211b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java @@ -163,7 +163,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerFacto return ActionResult.SUCCESS; } - if (EquinePredicates.MAGI.test(player)) { + if (EquinePredicates.PLAYER_UNICORN.test(player)) { player.playSound(SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 2, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java index bac63072..fa30f726 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java @@ -287,7 +287,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste @Override public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) { - if (EquinePredicates.MAGI.test(player)) { + if (EquinePredicates.PLAYER_UNICORN.test(player)) { ItemStack currentItem = player.getStackInHand(Hand.MAIN_HAND); if (currentItem != null diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java index a7c197e3..f427df9a 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java @@ -22,7 +22,7 @@ public class CloudFenceBlock extends FenceBlock implements Gas { @Override public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { - return getGasType(state) == CloudType.NORMAL; + return getGasType(state).isTranslucent(); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java index 2ef2d1b5..9de4cfdd 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudInteractionContext.java @@ -1,10 +1,7 @@ package com.minelittlepony.unicopia.gas; import com.minelittlepony.unicopia.EquinePredicates; -import com.minelittlepony.unicopia.entity.CloudEntity; - import net.minecraft.entity.Entity; -import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; public interface CloudInteractionContext { @@ -23,32 +20,34 @@ public interface CloudInteractionContext { boolean canTouch(CloudType type); + interface Holder extends CloudInteractionContext { + CloudInteractionContext getCloudInteractionContext(); + + @Override + default boolean isPlayer() { + return getCloudInteractionContext().isPlayer(); + } + + @Override + default boolean isPegasis() { + return getCloudInteractionContext().isPegasis(); + } + + @Override + default boolean canTouch(CloudType type) { + return getCloudInteractionContext().canTouch(type); + } + } + class Impl implements CloudInteractionContext { - private static final CloudInteractionContext EMPTY = type -> false; + public static final CloudInteractionContext EMPTY = type -> true; private final boolean isPlayer; private final boolean isPegasis; private Impl(Entity entity) { this.isPlayer = entity instanceof PlayerEntity; - this.isPegasis = isPegasis(entity); - } - - private boolean isPegasis(Entity entity) { - if (entity instanceof PlayerEntity) { - return EquinePredicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)entity) - || (EquinePredicates.MAGI.test(entity) && CloudEntity.getFeatherEnchantStrength((PlayerEntity)entity) > 0); - } - - if (entity instanceof ItemEntity) { - return EquinePredicates.ITEM_INTERACT_WITH_CLOUDS.test((ItemEntity)entity); - } - - if (entity instanceof CloudEntity && entity.hasVehicle()) { - return isPegasis(entity.getVehicle()); - } - - return false; + this.isPegasis = EquinePredicates.ENTITY_INTERACT_WITH_CLOUD_BLOCKS.test(entity); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java b/src/main/java/com/minelittlepony/unicopia/gas/Gas.java index ec09d689..d40f253e 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/Gas.java @@ -58,7 +58,7 @@ public interface Gas { } } - if (!EquinePredicates.INTERACT_WITH_CLOUDS.apply(player)) { + if (!EquinePredicates.PLAYER_PEGASUS.test(player)) { return type != CloudType.ENCHANTED; } diff --git a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java b/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java index 62e60b09..78e7b0c1 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java @@ -63,7 +63,7 @@ public class BagOfHoldingItem extends Item implements MagicalItem { @Override public TypedActionResult use(World world, PlayerEntity player, Hand hand) { - if (!EquinePredicates.MAGI.test(player)) { + if (!EquinePredicates.PLAYER_UNICORN.test(player)) { return super.use(world, player, hand); } @@ -91,7 +91,7 @@ public class BagOfHoldingItem extends Item implements MagicalItem { Box box = new Box(pos.offset(bhit.getSide())).expand(0.5); - List itemsAround = world.getEntities(player, box, EquinePredicates.ITEMS); + List itemsAround = world.getEntities(player, box, EquinePredicates.IS_VALID_ITEM); if (itemsAround.size() > 0) { BagOfHoldingInventory inventory = BagOfHoldingInventory.getInventoryFromStack(stack); diff --git a/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java b/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java index 22521570..d23b912d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/EnchantedStaffItem.java @@ -51,7 +51,7 @@ public class EnchantedStaffItem extends StaffItem implements Affine, TossableIte @Override public TypedActionResult use(World world, PlayerEntity player, Hand hand) { - if (EquinePredicates.MAGI.test(player) && hand == Hand.MAIN_HAND) { + if (EquinePredicates.PLAYER_UNICORN.test(player) && hand == Hand.MAIN_HAND) { ItemStack itemstack = player.getStackInHand(hand); player.swingHand(hand); @@ -64,8 +64,7 @@ public class EnchantedStaffItem extends StaffItem implements Affine, TossableIte @Override public void onStoppedUsing(ItemStack itemstack, World world, LivingEntity entity, int timeLeft) { - if (EquinePredicates.MAGI.test(entity) && entity instanceof PlayerEntity) { - + if (EquinePredicates.PLAYER_UNICORN.test(entity)) { int i = getMaxUseTime(itemstack) - timeLeft; if (i > 10 && canBeThrown(itemstack)) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java b/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java index a197ff4a..ec35f533 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/MagicGemItem.java @@ -71,7 +71,7 @@ public class MagicGemItem extends Item implements Castable { Hand hand = context.getHand(); PlayerEntity player = context.getPlayer(); - if (hand != Hand.MAIN_HAND || !EquinePredicates.MAGI.test(player)) { + if (hand != Hand.MAIN_HAND || !EquinePredicates.PLAYER_UNICORN.test(player)) { return ActionResult.PASS; } @@ -113,7 +113,7 @@ public class MagicGemItem extends Item implements Castable { ItemStack stack = player.getStackInHand(hand); - if (!EquinePredicates.MAGI.test(player)) { + if (!EquinePredicates.PLAYER_UNICORN.test(player)) { return new TypedActionResult<>(ActionResult.PASS, stack); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java b/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java index d1812c1a..660cbc75 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PredicatedBlockItem.java @@ -4,6 +4,7 @@ import java.util.function.Predicate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -13,9 +14,9 @@ import net.minecraft.world.World; public class PredicatedBlockItem extends BlockItem { - private final Predicate abilityTest; + private final Predicate abilityTest; - public PredicatedBlockItem(Block block, Item.Settings settings, Predicate abilityTest) { + public PredicatedBlockItem(Block block, Item.Settings settings, Predicate abilityTest) { super(block, settings); this.abilityTest = abilityTest; diff --git a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java b/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java index fe84abb3..d93029f8 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java @@ -39,7 +39,7 @@ public class SpellbookItem extends BookItem { @Nullable PlayerEntity player = context.getPlayer(); - if (!context.getWorld().isClient && EquinePredicates.MAGI.test(player)) { + if (!context.getWorld().isClient && EquinePredicates.PLAYER_UNICORN.test(player)) { BlockPos pos = context.getBlockPos().offset(context.getSide()); double diffX = player.getX() - (pos.getX() + 0.5); diff --git a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java index c15137b6..bc019106 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java @@ -63,7 +63,7 @@ public class StaffItem extends SwordItem { public boolean postHit(ItemStack stack, LivingEntity entity, LivingEntity attacker) { super.postHit(stack, entity, attacker); - if (EquinePredicates.MAGI.test(entity)) { + if (EquinePredicates.PLAYER_UNICORN.test(entity)) { return castContainedEffect(stack, entity, attacker); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index 148fa587..1894617c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -45,13 +45,13 @@ public interface UItems { CloudPlacerItem CONSTRUCTION_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.CONSTRUCTION_CLOUD), "construction_cloud_spawner"); CloudPlacerItem WILD_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.WILD_CLOUD), "wild_cloud_spawner"); - Item CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "cloud_block"); - Item ENCHANTED_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "enchanted_cloud_block"); - Item DENSE_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "dense_cloud_block"); + Item CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "cloud_block"); + Item ENCHANTED_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "enchanted_cloud_block"); + Item DENSE_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "dense_cloud_block"); - Item CLOUD_STAIRS = register(new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_stairs"); - Item CLOUD_FENCE = register(new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_fence"); - Item CLOUD_ANVIL = register(new PredicatedBlockItem(UBlocks.CLOUD_ANVIL, new Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_anvil"); + Item CLOUD_STAIRS = register(new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "cloud_stairs"); + Item CLOUD_FENCE = register(new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS), "cloud_fence"); + Item CLOUD_ANVIL = register(new PredicatedBlockItem(UBlocks.CLOUD_ANVIL, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS), "cloud_anvil"); Item MUSIC_DISC_CRUSADE = register(createRecord(USounds.RECORD_CRUSADE), "music_disc_crusade"); Item MUSIC_DISC_PET = register(createRecord(USounds.RECORD_PET), "music_disc_pet"); @@ -72,9 +72,9 @@ public interface UItems { Item SUGAR_BLOCK = register(new BlockItem(UBlocks.SUGAR_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)), "sugar_block"); - Item CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_slab"); - Item ENCHANTED_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "enchanted_cloud_slab"); - Item DENSE_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "dense_cloud_slab"); + Item CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "cloud_slab"); + Item ENCHANTED_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "enchanted_cloud_slab"); + Item DENSE_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "dense_cloud_slab"); MagicGemItem GEM = register(new MagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)), "gem"); MagicGemItem CORRUPTED_GEM = register(new CursedMagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)), "corrupted_gem"); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java b/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java index 01c30d09..7a38b7f5 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/CasterUtils.java @@ -44,7 +44,7 @@ public class CasterUtils { } static Stream> findAllSpellsInRange(Caster source, Box bb) { - return source.getWorld().getEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof Caster || EquinePredicates.MAGI.test(e))).stream() + return source.getWorld().getEntities(source.getEntity(), bb, e -> !e.removed && (e instanceof Caster || EquinePredicates.PLAYER_UNICORN.test(e))).stream() .map(CasterUtils::toCaster) .filter(o -> o.isPresent() && o.get() != source) .map(Optional::get); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java index 63442902..21d52475 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FireSpell.java @@ -179,7 +179,7 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, protected boolean applyEntitySingle(Entity owner, World world, Entity e) { if ((!e.equals(owner) || - (owner instanceof PlayerEntity && !EquinePredicates.MAGI.test(owner))) && !(e instanceof ItemEntity) + (owner instanceof PlayerEntity && !EquinePredicates.PLAYER_UNICORN.test(owner))) && !(e instanceof ItemEntity) && !(e instanceof IMagicals)) { e.setOnFireFor(60); e.damage(getDamageCause(e, (LivingEntity)owner), 0.1f); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java index 34a963ae..38f5e2eb 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java @@ -95,7 +95,7 @@ public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements Attach Entity owner = source.getOwner(); - boolean ownerIsValid = source.getAffinity() != Affinity.BAD && EquinePredicates.MAGI.test(owner); + boolean ownerIsValid = source.getAffinity() != Affinity.BAD && EquinePredicates.PLAYER_UNICORN.test(owner); Vec3d origin = source.getOriginVector(); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java index 881135f4..098bc8ad 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityContextImpl.java @@ -6,13 +6,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.gas.CloudInteractionContext; -import com.minelittlepony.unicopia.gas.CloudType; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityContextImpl; @Mixin(EntityContextImpl.class) -abstract class MixinEntityContextImpl implements CloudInteractionContext { +abstract class MixinEntityContextImpl implements CloudInteractionContext.Holder { private CloudInteractionContext cloudContext; @Inject(method = "(Lnet/minecraft/entity/Entity;)V", at = @At("RETURN")) @@ -21,17 +19,7 @@ abstract class MixinEntityContextImpl implements CloudInteractionContext { } @Override - public boolean isPlayer() { - return cloudContext != null && cloudContext.isPlayer(); - } - - @Override - public boolean isPegasis() { - return cloudContext != null && cloudContext.isPegasis(); - } - - @Override - public boolean canTouch(CloudType type) { - return cloudContext != null && cloudContext.canTouch(type); + public CloudInteractionContext getCloudInteractionContext() { + return cloudContext == null ? CloudInteractionContext.Impl.EMPTY : cloudContext; } }