diff --git a/src/main/java/com/minelittlepony/unicopia/EquineContext.java b/src/main/java/com/minelittlepony/unicopia/EquineContext.java index 2bd9bf0b..d9dd0a9f 100644 --- a/src/main/java/com/minelittlepony/unicopia/EquineContext.java +++ b/src/main/java/com/minelittlepony/unicopia/EquineContext.java @@ -25,11 +25,16 @@ public interface EquineContext { return getCompositeRace().canInteractWithClouds(); } + default boolean hasFeatherTouch() { + return false; + } + static EquineContext of(ShapeContext context) { if (context == ShapeContext.absent()) { return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(ABSENT); } - return context instanceof EquineContext c ? c : ABSENT; + EquineContext result = context instanceof Container c ? c.get() : ABSENT; + return result == null ? ABSENT : result; } static EquineContext of(ItemUsageContext context) { @@ -42,4 +47,8 @@ public interface EquineContext { } return MoreObjects.firstNonNull(Equine.of(entity).orElse(null), ABSENT); } + + interface Container { + EquineContext get(); + } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java index 490d7e4d..2479021c 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudBlock.java @@ -171,7 +171,7 @@ public class CloudBlock extends Block implements CloudLike { } protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) { - return context.collidesWithClouds(); + return context.collidesWithClouds() || context.hasFeatherTouch(); } @SuppressWarnings("deprecation") diff --git a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudPillarBlock.java b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudPillarBlock.java index baeb2f16..690cbf75 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudPillarBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/cloud/CloudPillarBlock.java @@ -63,24 +63,7 @@ public class CloudPillarBlock extends CloudBlock { @Override protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, EquineContext equineContext) { - var axis = state.get(AXIS); - - int[] offsets = { axis.choose(1, 0, 0), axis.choose(0, 1, 0), axis.choose(0, 0, 1) }; - float capOffset = 11F / 16F; - VoxelShape core = Block.createCuboidShape( - axis.choose(0, 1, 1), axis.choose(1, 0, 1), axis.choose(1, 1, 0), - 16 - axis.choose(0, 1, 1), 16 - axis.choose(1, 0, 1), 16 - axis.choose(1, 1, 0) - ); - VoxelShape foot = Block.createCuboidShape(0, 0, 0, 16 - (11 * offsets[0]), 16 - (11 * offsets[1]), 16 - (11 * offsets[2])); - VoxelShape cap = foot.offset(capOffset * offsets[0], capOffset * offsets[1], capOffset * offsets[2]); - var temp = new VoxelShape[] { - core, - VoxelShapes.union(core, foot), - VoxelShapes.union(core, cap), - VoxelShapes.union(core, cap, foot) - }; - return temp[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)]; - //return SHAPES.apply(state.get(AXIS))[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)]; + return SHAPES.apply(state.get(AXIS))[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)]; } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 86ea4261..fecfe073 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -30,6 +30,7 @@ import com.minelittlepony.unicopia.input.Heuristic; import com.minelittlepony.unicopia.input.Interactable; import com.minelittlepony.unicopia.item.GlassesItem; import com.minelittlepony.unicopia.item.UItems; +import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.network.datasync.EffectSync; import com.minelittlepony.unicopia.network.datasync.Transmittable; import com.minelittlepony.unicopia.particle.ParticleUtils; @@ -198,6 +199,11 @@ public abstract class Living implements Equine, Caste return vehicle != null && getCarrierId().filter(vehicle.getUuid()::equals).isPresent(); } + @Override + public boolean hasFeatherTouch() { + return EnchantmentHelper.getEquipmentLevel(UEnchantments.FEATHER_TOUCH, entity) > 0; + } + @Override public boolean beforeUpdate() { if (EffectUtils.getAmplifier(entity, UEffects.PARALYSIS) > 1 && entity.getVelocity().horizontalLengthSquared() > 0) { @@ -205,7 +211,6 @@ public abstract class Living implements Equine, Caste updateVelocity(); } - //transportation.updateSupportingEntity(); return false; } diff --git a/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java b/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java index f208e723..d4b34d81 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/cloud/CloudBlockItem.java @@ -19,8 +19,7 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -public class CloudBlockItem -extends BlockItem { +public class CloudBlockItem extends BlockItem { public CloudBlockItem(Block block, Item.Settings settings) { super(block, settings); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/UEnchantments.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/UEnchantments.java index 2085f490..a5143773 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/UEnchantments.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/UEnchantments.java @@ -40,6 +40,15 @@ public interface UEnchantments { */ Enchantment PADDED = register("padded", new SimpleEnchantment(Options.armor().rarity(Rarity.UNCOMMON).maxLevel(3).traded().table())); + /** + * Allows non-flying races to mine and interact with cloud blocks + * + * Appears in: + * - Trades + * - Enchanting Table + */ + Enchantment FEATHER_TOUCH = register("feather_touch", new SimpleEnchantment(Options.create(EnchantmentTarget.BREAKABLE, UEnchantmentValidSlots.HANDS).rarity(Rarity.UNCOMMON).traded().table())); + /** * Heavy players move more slowly but are less likely to be flung around wildly. * diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityShapeContext.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityShapeContext.java index 9e375403..b0930e75 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityShapeContext.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntityShapeContext.java @@ -9,15 +9,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.EquineContext; -import com.minelittlepony.unicopia.Race; - import net.minecraft.block.EntityShapeContext; import net.minecraft.entity.Entity; import net.minecraft.fluid.FluidState; import net.minecraft.item.ItemStack; @Mixin(EntityShapeContext.class) -abstract class MixinEntityShapeContext implements EquineContext { +abstract class MixinEntityShapeContext implements EquineContext.Container { private EquineContext equineContext; @Inject(method = "", at = @At("TAIL")) @@ -26,22 +24,7 @@ abstract class MixinEntityShapeContext implements EquineContext { } @Override - public Race getSpecies() { - return equineContext.getSpecies(); - } - - @Override - public Race.Composite getCompositeRace() { - return equineContext.getCompositeRace(); - } - - @Override - public float getCloudWalkingStrength() { - return equineContext.getCloudWalkingStrength(); - } - - @Override - public boolean collidesWithClouds() { - return equineContext.collidesWithClouds(); + public EquineContext get() { + return equineContext; } } diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 35f8c79c..23edf9ea 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -1339,6 +1339,8 @@ "enchantment.unicopia.heart_bound.desc": "Causes an item to stay with you after you die", "enchantment.unicopia.consumption": "Consumption", "enchantment.unicopia.consumption.desc": "Converts drops mined using a tool into raw experience", + "enchantment.unicopia.feather_touch": "Feather Touch", + "enchantment.unicopia.feather_touch.desc": "Allows breaking and placing cloud blocks when held", "commands.race.success.self": "Set own race to %1$s", "commands.race.success": "%1$s changed race to %2$s", @@ -1615,6 +1617,8 @@ "advancements.unicopia.lightning_bug.description": "Attract 10 lightning strikes as a changeling", "advancements.unicopia.wonder_bolt.title": "Wonder Bolt", "advancements.unicopia.wonder_bolt.description": "Attract 10 lightning strikes", + "advancements.unicopia.bait.title": "Is This Bait?", + "advancements.unicopia.bait.description": "Put some worms on a hook", "advancements.unicopia.jar.title": "Oh wow. What's this?", "advancements.unicopia.jar.description": "Find an empty jar", "advancements.unicopia.gotcha.title": "Got'cha!", diff --git a/src/main/resources/data/unicopia/tags/items/groups/earth_pony.json b/src/main/resources/data/unicopia/tags/items/groups/earth_pony.json index e3ec6fc3..51b9f951 100644 --- a/src/main/resources/data/unicopia/tags/items/groups/earth_pony.json +++ b/src/main/resources/data/unicopia/tags/items/groups/earth_pony.json @@ -58,6 +58,7 @@ "unicopia:crispy_hay_fries", "unicopia:horse_shoe_fries", "unicopia:wheat_worms", + "unicopia:baited_fishing_rod", "unicopia:worm_block", "unicopia:muffin", "unicopia:acorn",