Added feather touch enchantment

This commit is contained in:
Sollace 2024-03-28 15:32:21 +00:00
parent 74a11086d1
commit 82b74ecb18
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
9 changed files with 36 additions and 43 deletions

View file

@ -25,11 +25,16 @@ public interface EquineContext {
return getCompositeRace().canInteractWithClouds(); return getCompositeRace().canInteractWithClouds();
} }
default boolean hasFeatherTouch() {
return false;
}
static EquineContext of(ShapeContext context) { static EquineContext of(ShapeContext context) {
if (context == ShapeContext.absent()) { if (context == ShapeContext.absent()) {
return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(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) { static EquineContext of(ItemUsageContext context) {
@ -42,4 +47,8 @@ public interface EquineContext {
} }
return MoreObjects.firstNonNull(Equine.of(entity).orElse(null), ABSENT); return MoreObjects.firstNonNull(Equine.of(entity).orElse(null), ABSENT);
} }
interface Container {
EquineContext get();
}
} }

View file

@ -171,7 +171,7 @@ public class CloudBlock extends Block implements CloudLike {
} }
protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) { protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) {
return context.collidesWithClouds(); return context.collidesWithClouds() || context.hasFeatherTouch();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View file

@ -63,24 +63,7 @@ public class CloudPillarBlock extends CloudBlock {
@Override @Override
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, EquineContext equineContext) { protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, EquineContext equineContext) {
var axis = state.get(AXIS); return SHAPES.apply(state.get(AXIS))[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)];
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)];
} }
@Override @Override

View file

@ -30,6 +30,7 @@ import com.minelittlepony.unicopia.input.Heuristic;
import com.minelittlepony.unicopia.input.Interactable; import com.minelittlepony.unicopia.input.Interactable;
import com.minelittlepony.unicopia.item.GlassesItem; import com.minelittlepony.unicopia.item.GlassesItem;
import com.minelittlepony.unicopia.item.UItems; 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.EffectSync;
import com.minelittlepony.unicopia.network.datasync.Transmittable; import com.minelittlepony.unicopia.network.datasync.Transmittable;
import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.ParticleUtils;
@ -198,6 +199,11 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
return vehicle != null && getCarrierId().filter(vehicle.getUuid()::equals).isPresent(); return vehicle != null && getCarrierId().filter(vehicle.getUuid()::equals).isPresent();
} }
@Override
public boolean hasFeatherTouch() {
return EnchantmentHelper.getEquipmentLevel(UEnchantments.FEATHER_TOUCH, entity) > 0;
}
@Override @Override
public boolean beforeUpdate() { public boolean beforeUpdate() {
if (EffectUtils.getAmplifier(entity, UEffects.PARALYSIS) > 1 && entity.getVelocity().horizontalLengthSquared() > 0) { if (EffectUtils.getAmplifier(entity, UEffects.PARALYSIS) > 1 && entity.getVelocity().horizontalLengthSquared() > 0) {
@ -205,7 +211,6 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
updateVelocity(); updateVelocity();
} }
//transportation.updateSupportingEntity();
return false; return false;
} }

View file

@ -19,8 +19,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
public class CloudBlockItem public class CloudBlockItem extends BlockItem {
extends BlockItem {
public CloudBlockItem(Block block, Item.Settings settings) { public CloudBlockItem(Block block, Item.Settings settings) {
super(block, settings); super(block, settings);
} }

View file

@ -40,6 +40,15 @@ public interface UEnchantments {
*/ */
Enchantment PADDED = register("padded", new SimpleEnchantment(Options.armor().rarity(Rarity.UNCOMMON).maxLevel(3).traded().table())); 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. * Heavy players move more slowly but are less likely to be flung around wildly.
* *

View file

@ -9,15 +9,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.EquineContext; import com.minelittlepony.unicopia.EquineContext;
import com.minelittlepony.unicopia.Race;
import net.minecraft.block.EntityShapeContext; import net.minecraft.block.EntityShapeContext;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@Mixin(EntityShapeContext.class) @Mixin(EntityShapeContext.class)
abstract class MixinEntityShapeContext implements EquineContext { abstract class MixinEntityShapeContext implements EquineContext.Container {
private EquineContext equineContext; private EquineContext equineContext;
@Inject(method = "<init>", at = @At("TAIL")) @Inject(method = "<init>", at = @At("TAIL"))
@ -26,22 +24,7 @@ abstract class MixinEntityShapeContext implements EquineContext {
} }
@Override @Override
public Race getSpecies() { public EquineContext get() {
return equineContext.getSpecies(); return equineContext;
}
@Override
public Race.Composite getCompositeRace() {
return equineContext.getCompositeRace();
}
@Override
public float getCloudWalkingStrength() {
return equineContext.getCloudWalkingStrength();
}
@Override
public boolean collidesWithClouds() {
return equineContext.collidesWithClouds();
} }
} }

View file

@ -1339,6 +1339,8 @@
"enchantment.unicopia.heart_bound.desc": "Causes an item to stay with you after you die", "enchantment.unicopia.heart_bound.desc": "Causes an item to stay with you after you die",
"enchantment.unicopia.consumption": "Consumption", "enchantment.unicopia.consumption": "Consumption",
"enchantment.unicopia.consumption.desc": "Converts drops mined using a tool into raw experience", "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.self": "Set own race to %1$s",
"commands.race.success": "%1$s changed race to %2$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.lightning_bug.description": "Attract 10 lightning strikes as a changeling",
"advancements.unicopia.wonder_bolt.title": "Wonder Bolt", "advancements.unicopia.wonder_bolt.title": "Wonder Bolt",
"advancements.unicopia.wonder_bolt.description": "Attract 10 lightning strikes", "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.title": "Oh wow. What's this?",
"advancements.unicopia.jar.description": "Find an empty jar", "advancements.unicopia.jar.description": "Find an empty jar",
"advancements.unicopia.gotcha.title": "Got'cha!", "advancements.unicopia.gotcha.title": "Got'cha!",

View file

@ -58,6 +58,7 @@
"unicopia:crispy_hay_fries", "unicopia:crispy_hay_fries",
"unicopia:horse_shoe_fries", "unicopia:horse_shoe_fries",
"unicopia:wheat_worms", "unicopia:wheat_worms",
"unicopia:baited_fishing_rod",
"unicopia:worm_block", "unicopia:worm_block",
"unicopia:muffin", "unicopia:muffin",
"unicopia:acorn", "unicopia:acorn",