mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
More 1.21.2 updates
This commit is contained in:
parent
57ac3e4fee
commit
e06c6108f5
31 changed files with 148 additions and 120 deletions
|
@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
|||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||
import com.minelittlepony.unicopia.client.TextHelper;
|
||||
import com.minelittlepony.unicopia.entity.effect.EffectUtils;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
|
||||
import net.minecraft.item.Item.TooltipContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -25,7 +26,6 @@ import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
|||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
|
||||
public record CustomisedSpellType<T extends Spell> (
|
||||
SpellType<T> type,
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.unicopia.block.jar.EntityJarContents;
|
||||
import com.minelittlepony.unicopia.block.jar.FluidOnlyJarContents;
|
||||
import com.minelittlepony.unicopia.block.jar.ItemsJarContents;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.minelittlepony.unicopia.block.jar.FakeFluidJarContents;
|
||||
|
||||
|
@ -29,8 +30,6 @@ import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
|||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ItemActionResult;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -54,11 +53,11 @@ public class ItemJarBlock extends JarBlock implements BlockEntityProvider, Inven
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (hand == Hand.OFF_HAND) {
|
||||
return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
return ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION;
|
||||
}
|
||||
return world.getBlockEntity(pos, UBlockEntities.ITEM_JAR).map(data -> data.interact(player, hand)).orElse(ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION);
|
||||
return world.getBlockEntity(pos, UBlockEntities.ITEM_JAR).map(data -> data.interact(player, hand)).orElse(ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,10 +109,10 @@ public class ItemJarBlock extends JarBlock implements BlockEntityProvider, Inven
|
|||
super(UBlockEntities.ITEM_JAR, pos, state);
|
||||
}
|
||||
|
||||
public ItemActionResult interact(PlayerEntity player, Hand hand) {
|
||||
public ActionResult interact(PlayerEntity player, Hand hand) {
|
||||
TypedActionResult<JarContents> result = contents.interact(player, hand);
|
||||
contents = result.getValue();
|
||||
return result.getResult().isAccepted() ? ItemActionResult.SUCCESS : result.getResult() == ActionResult.FAIL ? ItemActionResult.FAIL : ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
contents = result.value();
|
||||
return result.result().isAccepted() ? ActionResult.SUCCESS : result.result() == ActionResult.FAIL ? ActionResult.FAIL : ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION;
|
||||
}
|
||||
|
||||
public JarContents getContents() {
|
||||
|
|
|
@ -8,12 +8,14 @@ import com.google.common.base.Suppliers;
|
|||
import com.minelittlepony.unicopia.block.ItemJarBlock.FluidJarContents;
|
||||
import com.minelittlepony.unicopia.block.ItemJarBlock.JarContents;
|
||||
import com.minelittlepony.unicopia.block.ItemJarBlock.TileData;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Bucketable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -23,7 +25,6 @@ import net.minecraft.registry.Registries;
|
|||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
|
||||
public record EntityJarContents (
|
||||
TileData tile,
|
||||
|
@ -31,7 +32,7 @@ public record EntityJarContents (
|
|||
Supplier<@Nullable Entity> entity
|
||||
) implements FluidJarContents {
|
||||
public EntityJarContents(TileData tile, NbtCompound compound) {
|
||||
this(tile, Registries.ENTITY_TYPE.getOrEmpty(Identifier.tryParse(compound.getString("entity"))).orElse(null));
|
||||
this(tile, Registries.ENTITY_TYPE.getOptionalValue(Identifier.tryParse(compound.getString("entity"))).orElse(null));
|
||||
}
|
||||
|
||||
public EntityJarContents(TileData tile) {
|
||||
|
@ -40,7 +41,7 @@ public record EntityJarContents (
|
|||
|
||||
public EntityJarContents(TileData tile, EntityType<?> entityType) {
|
||||
this(tile, entityType, Suppliers.memoize(() -> {
|
||||
return entityType == null ? null : entityType.create(tile.getWorld());
|
||||
return entityType == null ? null : entityType.create(tile.getWorld(), SpawnReason.LOAD);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.entity.EntityType;
|
|||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -44,7 +45,7 @@ public interface ElectrifiedBlock {
|
|||
default void triggerLightning(BlockState state, World world, BlockPos pos) {
|
||||
Vec3d center = pos.toCenterPos();
|
||||
if (world instanceof ServerWorld serverWorld) {
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world);
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world, SpawnReason.EVENT);
|
||||
world.getOtherEntities(null, Box.from(center).expand(7)).forEach(entity -> {
|
||||
shockEntity(serverWorld, center, lightning, entity);
|
||||
});
|
||||
|
@ -56,7 +57,7 @@ public interface ElectrifiedBlock {
|
|||
default void triggerLightning(BlockState state, World world, BlockPos pos, LivingEntity entity, boolean knockBack) {
|
||||
Vec3d center = pos.toCenterPos();
|
||||
if (world instanceof ServerWorld serverWorld) {
|
||||
shockEntity(serverWorld, center, EntityType.LIGHTNING_BOLT.create(world), entity);
|
||||
shockEntity(serverWorld, center, EntityType.LIGHTNING_BOLT.create(world, SpawnReason.EVENT), entity);
|
||||
}
|
||||
if (knockBack) {
|
||||
Vec3d offset = center.subtract(entity.getPos());
|
||||
|
@ -72,11 +73,11 @@ public interface ElectrifiedBlock {
|
|||
}
|
||||
float dist = (float)entity.getPos().distanceTo(center);
|
||||
if (dist < 4) {
|
||||
entity.onStruckByLightning(serverWorld, EntityType.LIGHTNING_BOLT.create(serverWorld));
|
||||
entity.onStruckByLightning(serverWorld, EntityType.LIGHTNING_BOLT.create(serverWorld, SpawnReason.EVENT));
|
||||
} else {
|
||||
float damage = 3 / dist;
|
||||
if (damage > 1) {
|
||||
entity.damage(entity.getDamageSources().lightningBolt(), damage);
|
||||
entity.damage(serverWorld, entity.getDamageSources().lightningBolt(), damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ButterflyEntity extends AmbientEntity {
|
|||
}
|
||||
|
||||
public static DefaultAttributeContainer.Builder createButterflyAttributes() {
|
||||
return createMobAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2);
|
||||
return createMobAttributes().add(EntityAttributes.MAX_HEALTH, 2);
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<? extends ButterflyEntity> type, WorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
|
||||
|
|
|
@ -26,11 +26,13 @@ import net.minecraft.entity.EntityDimensions;
|
|||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.entity.data.DataTracker.Builder;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -139,7 +141,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
|||
|
||||
if (!isClient()) {
|
||||
if (!checkConnection()) {
|
||||
kill();
|
||||
kill((ServerWorld)getWorld());
|
||||
}
|
||||
|
||||
spells.getSlots().get().ifPresent(spell -> {
|
||||
|
@ -157,7 +159,12 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
|||
}
|
||||
|
||||
@Override
|
||||
public void kill() {
|
||||
public boolean damage(ServerWorld world, DamageSource source, float amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kill(ServerWorld world) {
|
||||
setDead(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
|||
import net.minecraft.entity.data.DataTracker.Builder;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -183,7 +184,7 @@ public class FloatingArtefactEntity extends StationaryObjectEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean damage(DamageSource source, float damage) {
|
||||
public boolean damage(ServerWorld world, DamageSource source, float damage) {
|
||||
|
||||
if (getWorld().isClient || isInvulnerable()) {
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity.mob;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -18,6 +19,7 @@ import net.minecraft.entity.EntityStatuses;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.boss.ServerBossBar;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.damage.DamageTypes;
|
||||
|
@ -27,7 +29,6 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.context.LootContextParameterSet;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.loot.context.LootContextTypes;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -283,7 +284,7 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
return;
|
||||
}
|
||||
}
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(getWorld());
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(getWorld(), SpawnReason.EVENT);
|
||||
lightning.refreshPositionAfterTeleport(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
lightning.setCosmetic(cosmetic);
|
||||
getWorld().spawnEntity(lightning);
|
||||
|
@ -291,14 +292,13 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
super.damage(source, amount);
|
||||
public boolean damage(ServerWorld world, DamageSource source, float amount) {
|
||||
if (!cursed) {
|
||||
if (random.nextInt(35) == 0 || (source.isOf(DamageTypes.PLAYER_ATTACK) && EquineContext.of(source.getAttacker()).collidesWithClouds())) {
|
||||
if (getSize(1) < 2) {
|
||||
if (!getWorld().isClient() && getWorld().getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
RegistryKey<LootTable> table = getType().getLootTableId();
|
||||
LootContextParameterSet.Builder builder = new LootContextParameterSet.Builder((ServerWorld)this.getWorld())
|
||||
if (!world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
Optional<RegistryKey<LootTable>> table = getType().getLootTableKey();
|
||||
LootContextParameterSet.Builder builder = new LootContextParameterSet.Builder(world)
|
||||
.add(LootContextParameters.THIS_ENTITY, this)
|
||||
.add(LootContextParameters.ORIGIN, this.getPos())
|
||||
.add(LootContextParameters.DAMAGE_SOURCE, source)
|
||||
|
@ -310,7 +310,7 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
getRegistryManager().get(RegistryKeys.LOOT_TABLE).get(table)
|
||||
.generateLoot(builder.build(LootContextTypes.ENTITY), 0L, this::dropStack);
|
||||
}
|
||||
kill();
|
||||
kill(world);
|
||||
getWorld().sendEntityStatus(this, EntityStatuses.ADD_DEATH_PARTICLES);
|
||||
} else {
|
||||
split(2 + random.nextInt(4));
|
||||
|
|
|
@ -166,7 +166,7 @@ public class Acrobatics implements Tickable, NbtSerialisable {
|
|||
entity.setPosition(pos.getX() + 0.5, pos.getY() - (inverted ? 0 : 1), pos.getZ() + 0.5);
|
||||
entity.setVelocity(Vec3d.ZERO);
|
||||
entity.setSneaking(false);
|
||||
entity.stopFallFlying();
|
||||
entity.stopGliding();
|
||||
pony.getPhysics().cancelFlight(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
|||
|
||||
import net.minecraft.entity.player.HungerManager;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
public interface ManaConsumptionUtil {
|
||||
float MANA_PER_FOOD = 10F;
|
||||
|
@ -62,8 +63,8 @@ public interface ManaConsumptionUtil {
|
|||
float consumedHearts = Math.max(0, Math.min(availableHearts - 1, foodSubtract * HEARTS_PER_FOOD));
|
||||
foodSubtract = addExhaustion(hunger, foodSubtract);
|
||||
foodSubtract -= (consumedHearts / HEARTS_PER_FOOD);
|
||||
if (consumedHearts > 0) {
|
||||
entity.damage(UDamageSources.of(entity.getWorld()).damageOf(UDamageTypes.EXHAUSTION), consumedHearts);
|
||||
if (consumedHearts > 0 && !entity.getWorld().isClient) {
|
||||
entity.damage((ServerWorld)entity.getWorld(), UDamageSources.of(entity.getWorld()).damageOf(UDamageTypes.EXHAUSTION), consumedHearts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ public class PlayerAttributes implements Tickable {
|
|||
private final static List<ToggleableAttribute> ATTRIBUTES = List.of(
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("earth_pony_strength"), 0.6, Operation.ADD_MULTIPLIED_TOTAL),
|
||||
List.of(EntityAttributes.GENERIC_ATTACK_DAMAGE, EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE),
|
||||
List.of(EntityAttributes.ATTACK_DAMAGE, EntityAttributes.KNOCKBACK_RESISTANCE),
|
||||
pony -> pony.getCompositeRace().canUseEarth()
|
||||
),
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("earth_pony_knockback_resistance"), 6, Operation.ADD_VALUE),
|
||||
List.of(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE),
|
||||
List.of(EntityAttributes.KNOCKBACK_RESISTANCE),
|
||||
pony -> pony.getCompositeRace().canUseEarth() && pony.asEntity().isSneaking()
|
||||
),
|
||||
new ToggleableAttribute(
|
||||
|
@ -38,7 +38,7 @@ public class PlayerAttributes implements Tickable {
|
|||
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("pegasus_speed"), 0.2, Operation.ADD_MULTIPLIED_TOTAL),
|
||||
List.of(EntityAttributes.GENERIC_MOVEMENT_SPEED, EntityAttributes.GENERIC_ATTACK_SPEED),
|
||||
List.of(EntityAttributes.MOVEMENT_SPEED, EntityAttributes.ATTACK_SPEED),
|
||||
pony -> pony.getCompositeRace().canFly() && !pony.getCompositeRace().includes(Race.HIPPOGRIFF)
|
||||
),
|
||||
new ToggleableAttribute(
|
||||
|
@ -49,7 +49,7 @@ public class PlayerAttributes implements Tickable {
|
|||
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("hippogriff_speed"), 0.1, Operation.ADD_MULTIPLIED_TOTAL),
|
||||
List.of(EntityAttributes.GENERIC_MOVEMENT_SPEED, EntityAttributes.GENERIC_ATTACK_SPEED),
|
||||
List.of(EntityAttributes.MOVEMENT_SPEED, EntityAttributes.ATTACK_SPEED),
|
||||
pony -> pony.getCompositeRace().includes(Race.HIPPOGRIFF)
|
||||
),
|
||||
new ToggleableAttribute(
|
||||
|
@ -60,16 +60,16 @@ public class PlayerAttributes implements Tickable {
|
|||
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("kirin_knockback_vulneravility"), -2, Operation.ADD_VALUE),
|
||||
List.of(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE),
|
||||
List.of(EntityAttributes.KNOCKBACK_RESISTANCE),
|
||||
pony -> pony.getCompositeRace().includes(Race.KIRIN)
|
||||
),
|
||||
new ToggleableAttribute(
|
||||
new EntityAttributeModifier(Unicopia.id("kirin_rage"), 0.7, Operation.ADD_MULTIPLIED_TOTAL),
|
||||
List.of(EntityAttributes.GENERIC_MOVEMENT_SPEED,
|
||||
EntityAttributes.GENERIC_ATTACK_SPEED,
|
||||
EntityAttributes.GENERIC_ATTACK_DAMAGE,
|
||||
EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE,
|
||||
EntityAttributes.GENERIC_ATTACK_KNOCKBACK
|
||||
List.of(EntityAttributes.MOVEMENT_SPEED,
|
||||
EntityAttributes.ATTACK_SPEED,
|
||||
EntityAttributes.ATTACK_DAMAGE,
|
||||
EntityAttributes.KNOCKBACK_RESISTANCE,
|
||||
EntityAttributes.ATTACK_KNOCKBACK
|
||||
),
|
||||
SpellType.RAGE::isOn
|
||||
)
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellTyp
|
|||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
import com.minelittlepony.unicopia.item.EnchantableItem;
|
||||
import com.minelittlepony.unicopia.util.Copyable;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
import com.minelittlepony.unicopia.util.serialization.NbtSerialisable;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -15,7 +16,6 @@ import net.minecraft.nbt.NbtElement;
|
|||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
|
||||
public class PlayerCharmTracker implements NbtSerialisable, Copyable<PlayerCharmTracker> {
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -138,7 +139,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
@Override
|
||||
public boolean isFlying() {
|
||||
return isFlyingSurvival
|
||||
&& !entity.isFallFlying()
|
||||
&& !entity.isGliding()
|
||||
&& !entity.hasVehicle()
|
||||
&& !entity.getAbilities().creativeMode
|
||||
&& !entity.isSpectator();
|
||||
|
@ -299,7 +300,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
&& ticksInAir > 90) {
|
||||
|
||||
entity.getWorld().playSoundFromEntity(null, entity, USounds.Vanilla.ENTITY_PLAYER_BIG_FALL, SoundCategory.PLAYERS, 2, 1F);
|
||||
entity.damage(entity.getDamageSources().generic(), 3);
|
||||
entity.damage((ServerWorld)entity.getWorld(), entity.getDamageSources().generic(), 3);
|
||||
cancelFlight(true);
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +395,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
entity.setVelocity(velocity.toImmutable());
|
||||
|
||||
if (isFlying() && !entity.isFallFlying() && !pony.getAcrobatics().isHanging() && pony.isClient()) {
|
||||
if (isFlying() && !entity.isGliding() && !pony.getAcrobatics().isHanging() && pony.isClient()) {
|
||||
if (!MineLPDelegate.getInstance().getPlayerPonyRace(entity).isEquine() && getHorizontalMotion() > 0.03) {
|
||||
float pitch = ((LivingEntityDuck)entity).getLeaningPitch();
|
||||
if (pitch < 1) {
|
||||
|
@ -465,12 +466,16 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
applyThrust(velocity);
|
||||
} else if (entity.getWorld().random.nextInt(40) == 0) {
|
||||
entity.getWorld().playSoundFromEntity(null, entity, USounds.Vanilla.ENTITY_PLAYER_BIG_FALL, SoundCategory.PLAYERS, 2, 1.5F);
|
||||
entity.damage(entity.getDamageSources().generic(), 0.5F);
|
||||
if (!entity.getWorld().isClient) {
|
||||
entity.damage((ServerWorld)entity.getWorld(), entity.getDamageSources().generic(), 0.5F);
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isAvian() && !entity.getWorld().isClient) {
|
||||
if (pony.getObservedSpecies() != Race.BAT && entity.getWorld().random.nextInt(9000) == 0) {
|
||||
entity.dropItem(pony.getObservedSpecies() == Race.HIPPOGRIFF ? UItems.GRYPHON_FEATHER : UItems.PEGASUS_FEATHER);
|
||||
if (!entity.getWorld().isClient) {
|
||||
entity.dropItem((pony.getObservedSpecies() == Race.HIPPOGRIFF ? UItems.GRYPHON_FEATHER : UItems.PEGASUS_FEATHER).getDefaultStack(), false);
|
||||
}
|
||||
playSound(USounds.ENTITY_PLAYER_PEGASUS_MOLT, 0.3F, 1);
|
||||
UCriteria.SHED_FEATHER.trigger(entity);
|
||||
}
|
||||
|
@ -574,7 +579,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
}
|
||||
|
||||
if (pony.getMagicalReserves().getExhaustion().getPercentFill() > 0.99F && ticksInAir % 25 == 0 && !pony.isClient()) {
|
||||
entity.damage(pony.damageOf(UDamageTypes.EXHAUSTION), entity.getWorld().random.nextBetween(2, 4));
|
||||
entity.damage((ServerWorld)entity.getWorld(), pony.damageOf(UDamageTypes.EXHAUSTION), entity.getWorld().random.nextBetween(2, 4));
|
||||
|
||||
if (entity.getWorld().random.nextInt(110) == 1) {
|
||||
pony.getLevel().add(1);
|
||||
|
@ -666,7 +671,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
LivingEntity.FallSounds fallSounds = entity.getFallSounds();
|
||||
playSound(distance > 4 ? fallSounds.big() : fallSounds.small(), 1, entity.getSoundPitch());
|
||||
}
|
||||
entity.damage(entity.getDamageSources().flyIntoWall(), distance);
|
||||
if (!entity.getWorld().isClient) {
|
||||
entity.damage((ServerWorld)entity.getWorld(), entity.getDamageSources().flyIntoWall(), distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,7 +701,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
}
|
||||
|
||||
if (entity.getWorld().hasRain(entity.getBlockPos())) {
|
||||
applyTurbulance(velocity);
|
||||
if (!entity.getWorld().isClient) {
|
||||
applyTurbulance((ServerWorld)entity.getWorld(), velocity);
|
||||
}
|
||||
} else {
|
||||
float targetUpdraft = WeatherConditions.THERMAL_FIELD.getValue(entity.getWorld(), new BlockPos.Mutable().set(entity.getBlockPos())) / 3F;
|
||||
targetUpdraft *= 1 + motion;
|
||||
|
@ -768,17 +777,13 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
}
|
||||
}
|
||||
|
||||
private void applyTurbulance(MutableVector velocity) {
|
||||
int globalEffectStrength = entity.getWorld().getGameRules().getInt(UGameRules.WEATHER_EFFECTS_STRENGTH);
|
||||
private void applyTurbulance(ServerWorld world, MutableVector velocity) {
|
||||
int globalEffectStrength = world.getGameRules().getInt(UGameRules.WEATHER_EFFECTS_STRENGTH);
|
||||
float effectStrength = Math.min(1, (float)ticksInAir / MAX_TICKS_TO_WEATHER_EFFECTS) * (globalEffectStrength / 100F);
|
||||
Vec3d gust = WeatherConditions.getGustStrength(entity.getWorld(), entity.getBlockPos())
|
||||
.multiply(globalEffectStrength / 100D)
|
||||
.multiply(1 / (1 + Math.floor(pony.getLevel().get() / 10F)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (effectStrength * gust.getX() >= 1) {
|
||||
SoundEmitter.playSoundAt(entity, USounds.AMBIENT_WIND_GUST, SoundCategory.AMBIENT, 3, 1);
|
||||
}
|
||||
|
@ -796,7 +801,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
velocity.add(airflow.normalize(), windStrength.getValue());
|
||||
|
||||
if (!entity.getWorld().isClient && effectStrength > 0.9F && entity.getWorld().isThundering() && entity.getWorld().random.nextInt(9000) == 0) {
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld());
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld(), SpawnReason.EVENT);
|
||||
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
|
||||
|
||||
entity.getWorld().spawnEntity(lightning);
|
||||
|
@ -847,15 +852,17 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
if (damage > 0) {
|
||||
pony.subtractEnergyCost(damage / 5F);
|
||||
entity.damage(entity.getDamageSources().flyIntoWall(), Math.min(damage, entity.getHealth() - 1));
|
||||
if (!entity.getWorld().isClient) {
|
||||
entity.damage((ServerWorld)entity.getWorld(), entity.getDamageSources().flyIntoWall(), Math.min(damage, entity.getHealth() - 1));
|
||||
}
|
||||
if (!isEarthPonySmash) {
|
||||
UCriteria.BREAK_WINDOW.trigger(entity);
|
||||
}
|
||||
}
|
||||
|
||||
if (isEarthPonySmash) {
|
||||
if (isEarthPonySmash && !entity.getWorld().isClient) {
|
||||
DamageSource damageSource = pony.damageOf(UDamageTypes.STEAMROLLER);
|
||||
pony.findAllEntitiesInRange(speed + 4, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(EntityPredicates.VALID_LIVING_ENTITY)).forEach(e -> e.damage(damageSource, 50));
|
||||
pony.findAllEntitiesInRange(speed + 4, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(EntityPredicates.VALID_LIVING_ENTITY)).forEach(e -> e.damage((ServerWorld)entity.getWorld(), damageSource, 50));
|
||||
}
|
||||
|
||||
pony.updateVelocity();
|
||||
|
|
|
@ -482,9 +482,9 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
entity.playSound(SoundEvents.ENTITY_TURTLE_AMBIENT_LAND, 1, 1);
|
||||
}
|
||||
|
||||
if (entity.getAir() == -20) {
|
||||
if (entity.getAir() == -20 && !asWorld().isClient) {
|
||||
entity.setAir(0);
|
||||
entity.damage(entity.getDamageSources().dryOut(), 2);
|
||||
entity.damage((ServerWorld)asWorld(), entity.getDamageSources().dryOut(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
}
|
||||
|
||||
public ActionResult canSleepNow() {
|
||||
if (asWorld().getGameRules().getBoolean(UGameRules.DO_NOCTURNAL_BAT_PONIES) && getSpecies().isNocturnal()) {
|
||||
if (!asWorld().isClient && ((ServerWorld)asWorld()).getGameRules().getBoolean(UGameRules.DO_NOCTURNAL_BAT_PONIES) && getSpecies().isNocturnal()) {
|
||||
return asWorld().isDay() || asWorld().getAmbientDarkness() >= 4 ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
}
|
||||
|
||||
|
@ -899,7 +899,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
public void copyFrom(Pony oldPlayer, boolean alive) {
|
||||
boolean forcedSwap = (!alive
|
||||
&& entity instanceof ServerPlayerEntity
|
||||
&& entity.getWorld().getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH)
|
||||
&& ((ServerWorld)entity.getWorld()).getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH)
|
||||
&& oldPlayer.respawnRace.isUnset())
|
||||
|| oldPlayer.getSpecies().isUnset();
|
||||
|
||||
|
@ -919,7 +919,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
|
||||
if (!alive) {
|
||||
// putting it here instead of adding another injection point into ServerPlayerEntity.copyFrom()
|
||||
if (!asWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
|
||||
if (!((ServerWorld)asWorld()).getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
|
||||
PlayerInventory inventory = oldPlayer.asEntity().getInventory();
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.Entity.RemovalReason;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -23,20 +24,20 @@ public class EmptyJarItem extends BlockItem {
|
|||
&& entity.getWorld().isThundering()
|
||||
&& entity.getWorld().isSkyVisible(entity.getBlockPos())
|
||||
&& entity.getWorld().random.nextInt(130) == 0) {
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld());
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld(), SpawnReason.EVENT);
|
||||
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
|
||||
|
||||
entity.remove(RemovalReason.DISCARDED);
|
||||
entity.getWorld().spawnEntity(lightning);
|
||||
|
||||
ItemEntity neu = EntityType.ITEM.create(entity.getWorld());
|
||||
ItemEntity neu = EntityType.ITEM.create(entity.getWorld(), SpawnReason.TRIGGERED);
|
||||
neu.copyPositionAndRotation(entity);
|
||||
neu.setStack(new ItemStack(this == UItems.RAIN_CLOUD_JAR ? UItems.STORM_CLOUD_JAR : UItems.LIGHTNING_JAR));
|
||||
neu.setInvulnerable(true);
|
||||
|
||||
entity.getWorld().spawnEntity(neu);
|
||||
|
||||
ItemEntity copy = EntityType.ITEM.create(entity.getWorld());
|
||||
ItemEntity copy = EntityType.ITEM.create(entity.getWorld(), SpawnReason.TRIGGERED);
|
||||
copy.copyPositionAndRotation(entity);
|
||||
copy.setInvulnerable(true);
|
||||
copy.setStack(entity.getStack());
|
||||
|
|
|
@ -11,12 +11,12 @@ import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellTyp
|
|||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
|
||||
public interface EnchantableItem extends ItemConvertible {
|
||||
static CustomisedSpellType<?> getSpellEffect(ItemStack stack) {
|
||||
|
@ -43,7 +43,7 @@ public interface EnchantableItem extends ItemConvertible {
|
|||
|
||||
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);
|
||||
player.getItemCooldownManager().set(stack, 20);
|
||||
|
||||
if (!player.isCreative()) {
|
||||
if (stack.getCount() == 1) {
|
||||
|
@ -54,7 +54,7 @@ public interface EnchantableItem extends ItemConvertible {
|
|||
}
|
||||
}
|
||||
|
||||
return TypedActionResult.consume(result);
|
||||
return TypedActionResult.success(result);
|
||||
}
|
||||
|
||||
static boolean isEnchanted(ItemStack stack) {
|
||||
|
|
|
@ -13,14 +13,14 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AliasedBlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
@ -48,7 +48,7 @@ public class WeatherJarItem extends AliasedBlockItem implements Projectile, Proj
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
public ActionResult use(World world, PlayerEntity player, Hand hand) {
|
||||
if (player.shouldCancelInteraction()) {
|
||||
return super.use(world, player, hand);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class WeatherJarItem extends AliasedBlockItem implements Projectile, Proj
|
|||
}
|
||||
|
||||
if (type == Type.LIGHTNING) {
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world);
|
||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(world, SpawnReason.EVENT);
|
||||
lightning.refreshPositionAfterTeleport(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
world.spawnEntity(lightning);
|
||||
|
|
|
@ -8,11 +8,9 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
@ -30,7 +28,7 @@ public class CloudBlockItem extends BlockItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
public ActionResult use(World world, PlayerEntity user, Hand hand) {
|
||||
InteractionManager.getInstance().sendPlayerLookAngles(user);
|
||||
Vec3d targetPos = user.getEyePos().add(user.getRotationVec(1).multiply(1, 1.5, 1).normalize().multiply(2));
|
||||
ItemPlacementContext context = new ItemPlacementContext(user, hand, user.getStackInHand(hand), new BlockHitResult(
|
||||
|
@ -40,13 +38,7 @@ public class CloudBlockItem extends BlockItem {
|
|||
true
|
||||
));
|
||||
|
||||
ActionResult actionResult = place(context);
|
||||
|
||||
if (actionResult.isAccepted()) {
|
||||
return TypedActionResult.success(context.getStack(), world.isClient);
|
||||
}
|
||||
|
||||
return TypedActionResult.pass(user.getStackInHand(hand));
|
||||
return place(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,10 +34,10 @@ public record BreaksIntoItemComponent(
|
|||
);
|
||||
|
||||
public Optional<Item> getItemAfterBreaking() {
|
||||
return Registries.ITEM.getOrEmpty(itemAfterBreaking());
|
||||
return Registries.ITEM.getOptionalValue(itemAfterBreaking());
|
||||
}
|
||||
|
||||
public Optional<SoundEvent> getBreakingSound() {
|
||||
return Registries.SOUND_EVENT.getOrEmpty(breakingSound);
|
||||
return Registries.SOUND_EVENT.getOptionalValue(breakingSound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,13 +138,13 @@ public interface EnchantmentUtil {
|
|||
|
||||
@Deprecated
|
||||
static int getLevel(RegistryKey<Enchantment> enchantment, LivingEntity entity) {
|
||||
return entity.getRegistryManager().get(RegistryKeys.ENCHANTMENT).getEntry(enchantment)
|
||||
return entity.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT).getEntry(enchantment.getValue())
|
||||
.map(entry -> EnchantmentHelper.getEquipmentLevel(entry, entity))
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
private static int getTotalLevel(RegistryKey<Enchantment> enchantment, LivingEntity entity) {
|
||||
return entity.getRegistryManager().get(RegistryKeys.ENCHANTMENT).getEntry(enchantment)
|
||||
return entity.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT).getEntry(enchantment.getValue())
|
||||
.map(entry -> getTotalEquipmentLevel(entry, entity))
|
||||
.orElse(0);
|
||||
}
|
||||
|
|
|
@ -61,11 +61,11 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
}
|
||||
|
||||
public MagicProjectileEntity(World world, LivingEntity thrower) {
|
||||
super(UEntities.THROWN_ITEM, thrower, world);
|
||||
super(UEntities.THROWN_ITEM, thrower, world, UItems.GEMSTONE.getDefaultStack());
|
||||
}
|
||||
|
||||
protected MagicProjectileEntity(EntityType<? extends MagicProjectileEntity> type, World world, LivingEntity thrower) {
|
||||
super(type, thrower, world);
|
||||
super(type, thrower, world, UItems.GEMSTONE.getDefaultStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -221,8 +221,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
if (entity != null) {
|
||||
float damage = getThrowDamage();
|
||||
|
||||
if (damage > 0) {
|
||||
entity.damage(getDamageSources().thrown(this, getOwner()), getThrowDamage());
|
||||
if (damage > 0 && !getWorld().isClient) {
|
||||
entity.damage((ServerWorld)getWorld(), getDamageSources().thrown(this, getOwner()), getThrowDamage());
|
||||
}
|
||||
|
||||
forEachDelegates(effect -> effect.onImpact(this, hit), ProjectileDelegate.EntityHitListener.PREDICATE);
|
||||
|
@ -232,7 +232,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
public void knockback(LivingEntity target, DamageSource source, ItemStack weapon) {
|
||||
double d = weapon != null && getWorld() instanceof ServerWorld serverWorld ? EnchantmentHelper.modifyKnockback(serverWorld, weapon, target, source, 0) : 0;
|
||||
if (d > 0) {
|
||||
double e = Math.max(0, 1 - target.getAttributeValue(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE));
|
||||
double e = Math.max(0, 1 - target.getAttributeValue(EntityAttributes.KNOCKBACK_RESISTANCE));
|
||||
Vec3d vec3d = this.getVelocity().multiply(1, 0, 1).normalize().multiply(d * 0.6 * e);
|
||||
if (vec3d.lengthSquared() > 0) {
|
||||
target.addVelocity(vec3d.x, 0.1, vec3d.z);
|
||||
|
|
|
@ -120,7 +120,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (inGround) {
|
||||
if (inGroundTime > 0) {
|
||||
Vec3d vel = getVelocity();
|
||||
vel = vel.multiply(0, 1, 0);
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
playSound(USounds.Vanilla.ENTITY_ITEM_BREAK, 1, 1);
|
||||
});
|
||||
if (!stack.isEmpty()) {
|
||||
dropStack(stack);
|
||||
dropStack(sw, stack);
|
||||
}
|
||||
discard();
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
if (getVelocity().length() > 0.2F) {
|
||||
boolean ownerCanModify = !getWorld().isClient && Caster.of(getOwner()).filter(pony -> pony.canModifyAt(hit.getBlockPos())).isPresent();
|
||||
|
||||
if (ownerCanModify && getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
|
||||
if (ownerCanModify && ((ServerWorld)getWorld()).getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
|
||||
if ((!isBouncy() || getWorld().random.nextInt(200) == 0) && getWorld().getBlockState(hit.getBlockPos()).isIn(UTags.Blocks.FRAGILE)) {
|
||||
getWorld().breakBlock(hit.getBlockPos(), true);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ import net.minecraft.item.ProjectileItem;
|
|||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Position;
|
||||
|
@ -48,7 +48,7 @@ public interface Projectile extends ItemConvertible, ProjectileItem {
|
|||
return SETTINGS;
|
||||
}
|
||||
|
||||
default TypedActionResult<ItemStack> triggerThrow(World world, PlayerEntity player, Hand hand) {
|
||||
default ActionResult triggerThrow(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
if (!world.isClient) {
|
||||
|
@ -71,7 +71,7 @@ public interface Projectile extends ItemConvertible, ProjectileItem {
|
|||
stack.decrement(1);
|
||||
}
|
||||
|
||||
return TypedActionResult.success(stack, world.isClient());
|
||||
return ActionResult.SUCCESS_SERVER.withNewHandStack(stack);
|
||||
}
|
||||
|
||||
default ProjectileEntity createProjectile(ItemStack stack, World world, @Nullable PlayerEntity player) {
|
||||
|
|
|
@ -26,7 +26,7 @@ class FeatureRegistry {
|
|||
registries.getOptional(RegistryKeys.PLACED_FEATURE).ifPresent(registry -> {
|
||||
var lookup = registries.getOptional(RegistryKeys.CONFIGURED_FEATURE).orElseThrow();
|
||||
PLACED_FEATURES.forEach(entry -> {
|
||||
Registry.register(registry, entry.key(), entry.factory().apply(lookup.getEntry(entry.configuration()).orElseThrow()));
|
||||
Registry.register(registry, entry.key(), entry.factory().apply(lookup.getEntry(entry.configuration().getValue()).orElseThrow()));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@ public record Tree (
|
|||
});
|
||||
});
|
||||
registries.getOptional(RegistryKeys.PLACED_FEATURE).ifPresent(registry -> {
|
||||
var reg = registries.asDynamicRegistryManager().createRegistryLookup().getOrThrow(RegistryKeys.CONFIGURED_FEATURE);
|
||||
var reg = registries.asDynamicRegistryManager().getOrThrow(RegistryKeys.CONFIGURED_FEATURE);
|
||||
REGISTRY.stream().forEach(tree -> {
|
||||
tree.placements().forEach(placement -> {
|
||||
Registry.register(registry, placement.id(), new PlacedFeature(reg.getOrThrow(tree.configuredFeatureId()),
|
||||
|
@ -131,7 +131,7 @@ public record Tree (
|
|||
|
||||
public Tree build() {
|
||||
RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureId = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, id);
|
||||
Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, saplingConstructor.apply(new SaplingGenerator(id.toString(), Optional.of(configuredFeatureId), Optional.empty(), Optional.empty()), Block.Settings.copy(Blocks.OAK_SAPLING)), ItemGroups.NATURAL));
|
||||
Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, saplingConstructor.apply(new SaplingGenerator(id.toString(), Optional.of(configuredFeatureId), Optional.empty(), Optional.empty()), Block.Settings.copy(Blocks.OAK_SAPLING).registryKey(RegistryKey.of(RegistryKeys.BLOCK, id))), ItemGroups.NATURAL));
|
||||
Tree tree = new Tree(id, configParameters.apply(new TreeFeatureConfig.Builder(
|
||||
BlockStateProvider.of(logType),
|
||||
trunkPlacer,
|
||||
|
@ -142,7 +142,8 @@ public record Tree (
|
|||
.collect(Collectors.toUnmodifiableSet()),
|
||||
sapling,
|
||||
sapling.map(saplingBlock -> {
|
||||
Block flowerPot = Registry.register(Registries.BLOCK, saplingId.get().withPrefixedPath("potted_"), Blocks.createFlowerPotBlock(saplingBlock));
|
||||
RegistryKey<Block> flowerPotKey = RegistryKey.of(RegistryKeys.BLOCK, saplingId.get().withPrefixedPath("potted_"));
|
||||
Block flowerPot = Registry.register(Registries.BLOCK, saplingId.get().withPrefixedPath("potted_"), new FlowerPotBlock(saplingBlock, Blocks.createFlowerPotSettings().registryKey(flowerPotKey)));
|
||||
UBlocks.TRANSLUCENT_BLOCKS.add(flowerPot);
|
||||
return flowerPot;
|
||||
}));
|
||||
|
|
|
@ -149,7 +149,7 @@ public interface UWorldGen {
|
|||
.or(BiomeSelectors.tag(BiomeTags.IS_RIVER))
|
||||
.or(BiomeSelectors.includeByKey(BiomeKeys.STONY_SHORE))
|
||||
), GenerationStep.Feature.VEGETAL_DECORATION, SHELLS_PLACED_FEATURE);
|
||||
BiomeModifications.addCarver(BiomeSelectors.foundInOverworld(), GenerationStep.Carver.AIR, OVERWORLD_CLOUD_CARVER_CONFIG);
|
||||
BiomeModifications.addCarver(BiomeSelectors.foundInOverworld(), OVERWORLD_CLOUD_CARVER_CONFIG);
|
||||
UTreeGen.bootstrap();
|
||||
|
||||
OverworldBiomeSelectionCallback.EVENT.register(context -> {
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.minelittlepony.unicopia.util.Tickable;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
|
@ -113,7 +114,7 @@ public class ZapAppleStageStore extends PersistentState implements Tickable {
|
|||
StreamSupport.stream(BlockPos.iterateRandomly(world.random, 20, pos, 10).spliterator(), false)
|
||||
.filter(p -> world.isAir(p) && !world.isAir(p.down()) && world.isSkyVisible(p))
|
||||
.findFirst().ifPresent(p -> {
|
||||
LightningEntity bolt = EntityType.LIGHTNING_BOLT.create(world);
|
||||
LightningEntity bolt = EntityType.LIGHTNING_BOLT.create(world, SpawnReason.EVENT);
|
||||
bolt.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(pos));
|
||||
bolt.setCosmetic(true);
|
||||
world.spawnEntity(bolt);
|
||||
|
|
|
@ -3,7 +3,8 @@ package com.minelittlepony.unicopia.util;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.SheepEntity;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.ColorHelper.Argb;
|
||||
|
||||
import static net.minecraft.util.math.ColorHelper.*;
|
||||
|
||||
public interface ColorHelper {
|
||||
static int getRainbowColor(Entity entity, int speed, float tickDelta) {
|
||||
|
@ -14,7 +15,7 @@ public interface ColorHelper {
|
|||
float r = (entity.age % speed + tickDelta) / 25.0f;
|
||||
int fs = SheepEntity.getRgbColor(DyeColor.byId(p));
|
||||
int gs = SheepEntity.getRgbColor(DyeColor.byId(q));
|
||||
return Argb.lerp(r, fs, gs);
|
||||
return lerp(r, fs, gs);
|
||||
}
|
||||
|
||||
static float[] changeSaturation(float red, float green, float blue, float intensity) {
|
||||
|
@ -43,10 +44,10 @@ public interface ColorHelper {
|
|||
}
|
||||
|
||||
static int saturate(int color, float intensity) {
|
||||
float a = Argb.getAlpha(color) / 255F,
|
||||
red = Argb.getRed(color) / 255F,
|
||||
green = Argb.getGreen(color) / 255F,
|
||||
blue = Argb.getBlue(color) / 255F;
|
||||
float a = getAlpha(color) / 255F,
|
||||
red = getRed(color) / 255F,
|
||||
green = getGreen(color) / 255F,
|
||||
blue = getBlue(color) / 255F;
|
||||
float avg = (red + green + blue) / 3F;
|
||||
float r = avg + (red - avg) * intensity,
|
||||
g = avg + (green - avg) * intensity,
|
||||
|
@ -68,6 +69,6 @@ public interface ColorHelper {
|
|||
b = 1;
|
||||
}
|
||||
|
||||
return Argb.fromFloats(a, r, g, b);
|
||||
return fromFloats(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.block.dispenser.DispenserBehavior;
|
|||
import net.minecraft.block.dispenser.ItemDispenserBehavior;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPointer;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
|
@ -14,14 +13,13 @@ public interface Dispensable {
|
|||
private ActionResult result;
|
||||
@Override
|
||||
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack) {
|
||||
TypedActionResult<ItemStack> result = dispenseStack(source, stack);
|
||||
this.result = result.getResult();
|
||||
result = dispenseStack(source, stack);
|
||||
|
||||
if (!this.result.isAccepted()) {
|
||||
if (!result.isAccepted()) {
|
||||
return super.dispenseSilently(source, stack);
|
||||
}
|
||||
|
||||
return result.getValue();
|
||||
return result instanceof ActionResult.Success success ? success.getNewHandStack() : stack.split(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,5 +41,5 @@ public interface Dispensable {
|
|||
/**
|
||||
* Called to dispense this stack.
|
||||
*/
|
||||
TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack);
|
||||
ActionResult dispenseStack(BlockPointer source, ItemStack stack);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
||||
public record TypedActionResult<T> (ActionResult result, T value) {
|
||||
public static <T> TypedActionResult<T> success(T value) {
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, value);
|
||||
}
|
||||
|
||||
public static <T> TypedActionResult<T> pass(T value) {
|
||||
return new TypedActionResult<>(ActionResult.PASS, value);
|
||||
}
|
||||
|
||||
public static <T> TypedActionResult<T> fail(T value) {
|
||||
return new TypedActionResult<>(ActionResult.FAIL, value);
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class DynamicRegistry<T> implements RegistryBuilder.BootstrapFunction<T>
|
|||
if (added.getAndSet(true)) {
|
||||
return;
|
||||
}
|
||||
final WrapperLookup lookup = registries.asDynamicRegistryManager()::getWrapperOrThrow;
|
||||
final WrapperLookup lookup = registries.asDynamicRegistryManager()::getOrThrow;
|
||||
keys.forEach((key, entry) -> {
|
||||
if (!r.contains(key)) {
|
||||
Registry.register(r, key, entry.factory().apply(lookup, key));
|
||||
|
|
Loading…
Reference in a new issue