Merge pull request #74 from craisinlord/anthology-split
Anthology split
This commit is contained in:
341 files changed
+883
-16403
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.craisinlord.antarchy;
|
||||
|
||||
import com.craisinlord.antarchy.content.computer.AntarchyArchiveLocators;
|
||||
import com.craisinlord.antarchy.content.AntarchyAnthologyHooks;
|
||||
import com.craisinlord.antarchy.content.util.AttributeRangeInit;
|
||||
import com.craisinlord.antarchy.content.worldgen.VillagePoolAdditions;
|
||||
import com.craisinlord.integrated_api.events.lifecycle.ServerGoingToStartEvent;
|
||||
@@ -17,6 +18,7 @@ public class Antarchy {
|
||||
public static void init() {
|
||||
AttributeRangeInit.apply();
|
||||
AntarchyArchiveLocators.register();
|
||||
AntarchyAnthologyHooks.register();
|
||||
ServerGoingToStartEvent.EVENT.addListener(Antarchy::serverAboutToStart);
|
||||
}
|
||||
private static void serverAboutToStart(final ServerGoingToStartEvent event) {
|
||||
|
||||
@@ -156,7 +156,6 @@ public final class AntarchyConfigCatalog {
|
||||
|| name.equals("experimentalSettingsPopupDisabled")
|
||||
|| name.equals("unlockAllArchives")
|
||||
|| name.equals("entitySpecificFireOverlayEnabled")
|
||||
|| name.equals("dreamSandEnabled")
|
||||
|| name.startsWith("dreamSand")
|
||||
|| name.equals("ichorWitherEnabled")
|
||||
|| name.startsWith("diamondMinecart")
|
||||
|
||||
@@ -175,11 +175,7 @@ public final class AntarchySettings {
|
||||
private static double americanBonusSaturation = 1.0D;
|
||||
private static int americanRegenerationDurationTicks = 60;
|
||||
private static int americanRegenerationAmplifier = 0;
|
||||
private static boolean dreamSandEnabled = true;
|
||||
private static boolean entitySpecificFireOverlayEnabled = true;
|
||||
private static double dreamSandJumpVelocityMultiplier = 1.3D;
|
||||
private static double dreamSandGravityMultiplier = 0.45D;
|
||||
private static double dreamSandEffectDurationSeconds = 7.0D;
|
||||
private static double dreamSandFallingBlockGravityMultiplier = 0.4D;
|
||||
private static boolean ichorWitherEnabled = true;
|
||||
private static int nightmareHelmetArmorValue = 4;
|
||||
@@ -1926,46 +1922,14 @@ public final class AntarchySettings {
|
||||
americanRegenerationAmplifier = value;
|
||||
}
|
||||
|
||||
public static boolean dreamSandEnabled() {
|
||||
return dreamSandEnabled;
|
||||
}
|
||||
|
||||
public static boolean entitySpecificFireOverlayEnabled() {
|
||||
return entitySpecificFireOverlayEnabled;
|
||||
}
|
||||
|
||||
public static void setDreamSandEnabled(boolean value) {
|
||||
dreamSandEnabled = value;
|
||||
}
|
||||
|
||||
public static void setEntitySpecificFireOverlayEnabled(boolean value) {
|
||||
entitySpecificFireOverlayEnabled = value;
|
||||
}
|
||||
|
||||
public static double dreamSandJumpVelocityMultiplier() {
|
||||
return dreamSandJumpVelocityMultiplier;
|
||||
}
|
||||
|
||||
public static void setDreamSandJumpVelocityMultiplier(double value) {
|
||||
dreamSandJumpVelocityMultiplier = value;
|
||||
}
|
||||
|
||||
public static double dreamSandGravityMultiplier() {
|
||||
return dreamSandGravityMultiplier;
|
||||
}
|
||||
|
||||
public static void setDreamSandGravityMultiplier(double value) {
|
||||
dreamSandGravityMultiplier = value;
|
||||
}
|
||||
|
||||
public static double dreamSandEffectDurationSeconds() {
|
||||
return dreamSandEffectDurationSeconds;
|
||||
}
|
||||
|
||||
public static void setDreamSandEffectDurationSeconds(double value) {
|
||||
dreamSandEffectDurationSeconds = value;
|
||||
}
|
||||
|
||||
public static double dreamSandFallingBlockGravityMultiplier() {
|
||||
return dreamSandFallingBlockGravityMultiplier;
|
||||
}
|
||||
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
package com.craisinlord.antarchy.content;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import java.util.UUID;
|
||||
import com.craisinlord.anthology.portal.client.PortalClientHooks;
|
||||
import com.craisinlord.anthology.portal.PortalSettings;
|
||||
import com.craisinlord.anthology.portal.PortalHooks;
|
||||
import com.craisinlord.anthology.portal.PortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunProjectileEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.item.PortalGunItem;
|
||||
import com.craisinlord.antarchy.content.client.renderer.PortalGunMoonViewRenderer;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.item.BigBerthaItem;
|
||||
import com.craisinlord.antarchy.content.client.HerculesBeetleImpactShakeClientState;
|
||||
import com.craisinlord.anthology.shake.client.CameraShake;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectEligibility;
|
||||
import com.craisinlord.antarchy.content.enchantment.AntarchyEnchantments;
|
||||
import com.craisinlord.antarchy.content.entity.BedBugEntity;
|
||||
import com.craisinlord.antarchy.content.entity.portal.DimensionalTearEntity;
|
||||
import com.craisinlord.antarchy.content.entity.royal.QueenEntity;
|
||||
import com.craisinlord.antarchy.content.entity.royal.RoyalBlackHoleEntity;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.item.TemporalTunerAccess;
|
||||
import com.craisinlord.antarchy.content.item.TemporalTunerItem;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.craisinlord.anthology.effect.AnthologyEffects;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityHooks;
|
||||
import com.craisinlord.anthology.time.TimeDilationApi;
|
||||
import com.craisinlord.anthology.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.anthology.time.TimeDilationHooks;
|
||||
import com.craisinlord.anthology.time.TimeDilationMath;
|
||||
import com.craisinlord.anthology.time.client.ContractionAfterimages;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public final class AntarchyAnthologyHooks {
|
||||
private AntarchyAnthologyHooks() {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
GravityHooks.addInvertedRegion(ThoraxisUndersideManager::isInUnderside);
|
||||
GravityHooks.addInvertedFluid(AntarchyFluidChecks::isAntiwater);
|
||||
GravityHooks.addLoadListener(AntarchyAnthologyHooks::clearStaleUndersideInversion);
|
||||
TimeDilationHooks.addTrackedPredicate(entity -> entity instanceof Player player && TemporalTunerItem.isAvailable(player));
|
||||
TimeDilationHooks.addRateSource(AntarchyAnthologyHooks::temporalTunerRate);
|
||||
TimeDilationHooks.addFieldExclusion(AntarchyAnthologyHooks::excludedFromField);
|
||||
TimeDilationHooks.addChronosphereLevelSource(AntarchyEnchantments::chronosphereLevel);
|
||||
PortalHooks.setSettings(new AntarchyPortalSettings());
|
||||
PortalHooks.addTransitExclusion(entity -> entity instanceof PortalGunProjectileEntity);
|
||||
}
|
||||
|
||||
public static void registerClient() {
|
||||
PortalClientHooks.registerCustomView(portal -> portal instanceof PortalGunPortalEntity gunPortal && gunPortal.isMoonPortal(), PortalGunMoonViewRenderer::render);
|
||||
PortalClientHooks.setOutlinePolicy(AntarchyAnthologyHooks::outlinesPortal);
|
||||
CameraShake.addStrengthSource(cameraPos -> HerculesBeetleImpactShakeClientState.getTicks() / 25.0F * 2.0F);
|
||||
CameraShake.addStrengthSource(cameraPos -> BigBerthaItem.clientShakeTicks / 25.0F * 2.0F);
|
||||
ContractionAfterimages.addActivator(living -> living instanceof Player player
|
||||
&& TemporalTunerItem.isAvailable(player)
|
||||
&& TimeDilationApi.getRate(living) > 1.0D);
|
||||
}
|
||||
|
||||
private static boolean outlinesPortal(PortalEntity portal, LocalPlayer viewer) {
|
||||
if (!(portal instanceof PortalGunPortalEntity gunPortal) || gunPortal.getOwnerId() == null) {
|
||||
return false;
|
||||
}
|
||||
UUID owner = gunPortal.getOwnerId();
|
||||
return owner.equals(viewer.getUUID())
|
||||
|| owner.equals(heldGunOwner(viewer.getMainHandItem(), viewer.getUUID()))
|
||||
|| owner.equals(heldGunOwner(viewer.getOffhandItem(), viewer.getUUID()));
|
||||
}
|
||||
|
||||
private static UUID heldGunOwner(ItemStack stack, UUID fallback) {
|
||||
return stack.getItem() instanceof PortalGunItem ? PortalGunItem.getPortalOwnerId(stack, fallback) : null;
|
||||
}
|
||||
|
||||
private static final class AntarchyPortalSettings implements PortalSettings {
|
||||
@Override
|
||||
public boolean seeThroughEnabled() {
|
||||
return AntarchySettings.portalGunSeeThroughPortals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxLiveViews() {
|
||||
return AntarchySettings.portalGunMaxLiveViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double minFloorExitSpeed() {
|
||||
return AntarchySettings.portalGunMinFloorExitSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double maxExitSpeed() {
|
||||
return AntarchySettings.portalGunMaxExitSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fancySurfaces() {
|
||||
return AntarchySettings.portalGunFancyPortals();
|
||||
}
|
||||
}
|
||||
|
||||
private static double temporalTunerRate(Entity entity) {
|
||||
if (!(entity instanceof Player player) || !(player instanceof TemporalTunerAccess access)) {
|
||||
return TimeDilationMath.NORMAL_RATE;
|
||||
}
|
||||
if (TemporalTunerItem.isAvailable(player)) {
|
||||
return TemporalTunerItem.getRate(player);
|
||||
}
|
||||
access.antarchy$setTemporalTunerRate(TimeDilationMath.NORMAL_RATE);
|
||||
TemporalTunerItem.syncTooltipRate(player, TimeDilationMath.NORMAL_RATE);
|
||||
return TimeDilationMath.NORMAL_RATE;
|
||||
}
|
||||
|
||||
private static boolean excludedFromField(TimeDilationFieldEntity field, Entity entity) {
|
||||
if (!field.isOwnerAnchored() && entity instanceof RoyalBlackHoleEntity) {
|
||||
return true;
|
||||
}
|
||||
if (!(field.owner() instanceof QueenEntity)) {
|
||||
return false;
|
||||
}
|
||||
if (entity instanceof LivingEntity living && !RoyalEffectEligibility.canApplyDilated(living)) {
|
||||
return true;
|
||||
}
|
||||
return !field.isOwnerAnchored() && entity.getType().is(AntarchyTags.Entities.QUEEN_DOES_NOT_ATTACK);
|
||||
}
|
||||
|
||||
private static void clearStaleUndersideInversion(Entity entity) {
|
||||
if (!(entity instanceof Mob mob)
|
||||
|| !GravityApi.isGravityInverted(mob)
|
||||
|| !GravityApi.isGravityForced(mob)) {
|
||||
return;
|
||||
}
|
||||
MobEffectInstance invertedEffect = mob.getEffect(AnthologyEffects.inverted());
|
||||
boolean aboveUndersideExit = ThoraxisUndersideManager.isAboveUndersideExit(mob);
|
||||
int nearbyDimensionalTears = countNearbyDimensionalTears(mob);
|
||||
if (invertedEffect != null
|
||||
&& invertedEffect.isAmbient()
|
||||
&& !invertedEffect.isVisible()
|
||||
&& aboveUndersideExit) {
|
||||
clearInversion(mob);
|
||||
Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared stale underside inversion from loaded mob type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (invertedEffect != null
|
||||
&& mob instanceof BedBugEntity
|
||||
&& aboveUndersideExit
|
||||
&& ThoraxisUndersideManager.isThoraxis(mob.level())) {
|
||||
clearInversion(mob);
|
||||
Antarchy.LOGGER.warn(
|
||||
"[antarchy-gravity] cleared loaded inverted bed bug above underside exit type={} uuid={} pos=({}, {}, {}) dim={} effectDuration={} effectAmbient={} effectVisible={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect.getDuration(), invertedEffect.isAmbient(), invertedEffect.isVisible(), nearbyDimensionalTears
|
||||
);
|
||||
return;
|
||||
}
|
||||
Antarchy.LOGGER.info(
|
||||
"[antarchy-gravity] loaded inverted mob type={} uuid={} pos=({}, {}, {}) dim={} hasInvertedEffect={} effectDuration={} effectAmbient={} effectVisible={} aboveUndersideExit={} nearbyDimensionalTears={}",
|
||||
mob.getType(), mob.getUUID(), mob.getX(), mob.getY(), mob.getZ(),
|
||||
mob.level() != null ? mob.level().dimension().location() : "?",
|
||||
invertedEffect != null,
|
||||
invertedEffect != null ? invertedEffect.getDuration() : -1,
|
||||
invertedEffect != null && invertedEffect.isAmbient(),
|
||||
invertedEffect != null && invertedEffect.isVisible(),
|
||||
aboveUndersideExit,
|
||||
nearbyDimensionalTears
|
||||
);
|
||||
}
|
||||
|
||||
private static void clearInversion(Mob mob) {
|
||||
mob.removeEffect(AnthologyEffects.inverted());
|
||||
GravityApi.resetGravityState(mob);
|
||||
}
|
||||
|
||||
private static int countNearbyDimensionalTears(Mob mob) {
|
||||
if (!(mob.level() instanceof ServerLevel serverLevel)) {
|
||||
return -1;
|
||||
}
|
||||
return serverLevel.getEntitiesOfClass(
|
||||
DimensionalTearEntity.class,
|
||||
mob.getBoundingBox().inflate(48.0D),
|
||||
Entity::isAlive
|
||||
).size();
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import com.craisinlord.antarchy.content.entity.lucid.LucidEntity;
|
||||
import com.craisinlord.antarchy.content.entity.vortex.VortexChargeProjectileEntity;
|
||||
import com.craisinlord.antarchy.content.entity.vortex.VortexEntity;
|
||||
import com.craisinlord.antarchy.content.entity.vortex.WindVortexEntity;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.antarchy.content.entity.nightmare.NightmareEntity;
|
||||
import com.craisinlord.antarchy.content.entity.nightmare.NightmareBiteEntity;
|
||||
import com.craisinlord.antarchy.content.entity.nightmare.NightmarePortalEntity;
|
||||
@@ -97,8 +96,6 @@ public final class AntarchyObjects {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Supplier<EntityType<VortexChargeProjectileEntity>> VORTEX_CHARGE_PROJECTILE = (Supplier<EntityType<VortexChargeProjectileEntity>>) UNBOUND;
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Supplier<EntityType<TimeDilationFieldEntity>> TIME_DILATION_FIELD = (Supplier<EntityType<TimeDilationFieldEntity>>) UNBOUND;
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Supplier<EntityType<com.craisinlord.antarchy.content.entity.royal.RoyalBlackHoleEntity>> ROYAL_BLACK_HOLE = (Supplier<EntityType<com.craisinlord.antarchy.content.entity.royal.RoyalBlackHoleEntity>>) UNBOUND;
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Supplier<EntityType<com.craisinlord.antarchy.content.entity.royal.RoyalAssailantBlackHoleEntity>> ROYAL_ASSAILANT_BLACK_HOLE = (Supplier<EntityType<com.craisinlord.antarchy.content.entity.royal.RoyalAssailantBlackHoleEntity>>) UNBOUND;
|
||||
@@ -698,10 +695,6 @@ public final class AntarchyObjects {
|
||||
VORTEX_CHARGE_PROJECTILE = supplier;
|
||||
}
|
||||
|
||||
public static void setTimeDilationField(Supplier<EntityType<TimeDilationFieldEntity>> supplier) {
|
||||
TIME_DILATION_FIELD = supplier;
|
||||
}
|
||||
|
||||
public static void setRoyalBlackHole(Supplier<EntityType<com.craisinlord.antarchy.content.entity.royal.RoyalBlackHoleEntity>> supplier) {
|
||||
ROYAL_BLACK_HOLE = supplier;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.craisinlord.antarchy.content;
|
||||
|
||||
import com.craisinlord.anthology.time.TimeDilationTags;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -84,7 +85,7 @@ public final class AntarchyTags {
|
||||
public static final TagKey<EntityType<?>> LUCID_ANCHOR_IMMUNE = TagKey.create(Registries.ENTITY_TYPE, id("lucid_anchor_immune"));
|
||||
public static final TagKey<EntityType<?>> DIMENSIONAL_TEAR_COMMON_SPAWNS = TagKey.create(Registries.ENTITY_TYPE, id("dimensional_tear_common_spawns"));
|
||||
public static final TagKey<EntityType<?>> DIMENSIONAL_TEAR_RARE_SPAWNS = TagKey.create(Registries.ENTITY_TYPE, id("dimensional_tear_rare_spawns"));
|
||||
public static final TagKey<EntityType<?>> TIME_DILATION_IMMUNE = TagKey.create(Registries.ENTITY_TYPE, id("time_dilation_immune"));
|
||||
public static final TagKey<EntityType<?>> TIME_DILATION_IMMUNE = TimeDilationTags.TIME_DILATION_IMMUNE;
|
||||
public static final TagKey<EntityType<?>> QUEEN_DOES_NOT_ATTACK = TagKey.create(Registries.ENTITY_TYPE, id("queen_does_not_attack"));
|
||||
public static final TagKey<EntityType<?>> COMMANDED_BLACKLIST = TagKey.create(Registries.ENTITY_TYPE, id("commanded_blacklist"));
|
||||
public static final TagKey<EntityType<?>> DILATED_BLACKLIST = TagKey.create(Registries.ENTITY_TYPE, id("dilated_blacklist"));
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.block;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.UpwardFallingBlockEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -66,7 +66,7 @@ public class AntimetalScaffoldingBlock extends ScaffoldingBlock {
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
boolean inverted = context.getPlayer() != null && AntarchyGravityApi.isGravityInverted(context.getPlayer());
|
||||
boolean inverted = context.getPlayer() != null && GravityApi.isGravityInverted(context.getPlayer());
|
||||
int distance = getDistance(level, pos, inverted);
|
||||
if (inverted && distance >= 7) {
|
||||
return null;
|
||||
|
||||
+6
-6
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.block.PotentNyxiteBlock;
|
||||
import com.craisinlord.antarchy.content.block.state.PotentNyxiteState;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.client.particle.InvertedGeyserParticleOptions;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
@@ -333,9 +333,9 @@ public class PotentNyxiteBlockEntity extends BlockEntity {
|
||||
continue;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(entity);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(entity);
|
||||
Vec3 currentWorldVelocity = gravityDirection.isInverted()
|
||||
? AntarchyGravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), gravityDirection)
|
||||
? GravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), gravityDirection)
|
||||
: entity.getDeltaMovement();
|
||||
|
||||
double axisVelocity = currentWorldVelocity.y * eruptionDirection.getStepY();
|
||||
@@ -343,7 +343,7 @@ public class PotentNyxiteBlockEntity extends BlockEntity {
|
||||
Vec3 nextWorldVelocity = currentWorldVelocity.add(worldPush);
|
||||
entity.setDeltaMovement(
|
||||
gravityDirection.isInverted()
|
||||
? AntarchyGravityRotationUtil.vecWorldToPlayer(nextWorldVelocity, gravityDirection)
|
||||
? GravityRotationUtil.vecWorldToPlayer(nextWorldVelocity, gravityDirection)
|
||||
: nextWorldVelocity
|
||||
);
|
||||
entity.hurtMarked = true;
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package com.craisinlord.antarchy.content.block.entity;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.block.UndertrialSpawnerBlock;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.anthology.effect.AnthologyEffects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -116,7 +117,7 @@ public final class UndertrialSpawnerBlockEntity extends BlockEntity implements T
|
||||
mob.addEffect(new MobEffectInstance(AntarchyObjects.INVERTED_EFFECT.get(), EFFECT_DURATION, 0, false, true, true));
|
||||
int roll = mob.getRandom().nextInt(100);
|
||||
if (roll < 30) {
|
||||
mob.addEffect(new MobEffectInstance(effect("contracted"), EFFECT_DURATION, 0, false, true, true));
|
||||
mob.addEffect(new MobEffectInstance(AnthologyEffects.contracted(), EFFECT_DURATION, 0, false, true, true));
|
||||
} else if (roll < 50) {
|
||||
mob.addEffect(new MobEffectInstance(effect("shrinking"), EFFECT_DURATION, 0, false, true, true));
|
||||
} else if (roll < 65) {
|
||||
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class CameraShakeClientState {
|
||||
public static final double TORETERROR_RANGE = 48.0D;
|
||||
public static final float TORETERROR_STRENGTH = 1.0F;
|
||||
public static final double NIGHTMARE_RANGE = 32.0D;
|
||||
public static final float NIGHTMARE_STRENGTH = 1.35F;
|
||||
|
||||
private record Source(double range, float strength, BooleanSupplier active) {
|
||||
}
|
||||
|
||||
private record Impact(Vec3 position, float intensity, int remainingTicks, int totalTicks, float radius) {
|
||||
private Impact ticked() {
|
||||
return new Impact(position, intensity, remainingTicks - 1, totalTicks, radius);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<LivingEntity, Source> SOURCES = new HashMap<>();
|
||||
private static final java.util.List<Impact> IMPACTS = new java.util.ArrayList<>();
|
||||
|
||||
private CameraShakeClientState() {
|
||||
}
|
||||
|
||||
public static void register(LivingEntity entity, double range, float strength, BooleanSupplier active) {
|
||||
SOURCES.putIfAbsent(entity, new Source(range, strength, active));
|
||||
}
|
||||
|
||||
public static float getStrength(Vec3 cameraPos) {
|
||||
float total = 0.0F;
|
||||
Iterator<Map.Entry<LivingEntity, Source>> iterator = SOURCES.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<LivingEntity, Source> entry = iterator.next();
|
||||
LivingEntity entity = entry.getKey();
|
||||
Source source = entry.getValue();
|
||||
if (entity.isRemoved() || !entity.isAlive() || !source.active().getAsBoolean()) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
double distance = Math.sqrt(cameraPos.distanceToSqr(entity.position().add(0.0D, entity.getBbHeight() * 0.5D, 0.0D)));
|
||||
if (distance > source.range()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
total += (float) ((1.0D - distance / source.range()) * source.strength());
|
||||
}
|
||||
|
||||
Iterator<Impact> impactIterator = IMPACTS.iterator();
|
||||
while (impactIterator.hasNext()) {
|
||||
Impact impact = impactIterator.next();
|
||||
if (impact.remainingTicks() <= 0) {
|
||||
impactIterator.remove();
|
||||
continue;
|
||||
}
|
||||
double distance = Math.sqrt(cameraPos.distanceToSqr(impact.position()));
|
||||
if (distance > impact.radius()) {
|
||||
continue;
|
||||
}
|
||||
total += (float) ((1.0D - distance / impact.radius()) * impact.intensity() * (impact.remainingTicks() / (float) Math.max(1, impact.totalTicks())));
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public static void triggerImpact(Vec3 position, float intensity, int durationTicks, float radius) {
|
||||
int ticks = Math.max(1, durationTicks);
|
||||
IMPACTS.add(new Impact(position, intensity, ticks, ticks, Math.max(1.0F, radius)));
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
for (int i = IMPACTS.size() - 1; i >= 0; i--) {
|
||||
Impact impact = IMPACTS.get(i);
|
||||
if (impact.remainingTicks() <= 1) {
|
||||
IMPACTS.remove(i);
|
||||
} else {
|
||||
IMPACTS.set(i, impact.ticked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
SOURCES.clear();
|
||||
IMPACTS.clear();
|
||||
}
|
||||
}
|
||||
-171
@@ -1,171 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldSnapshot;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldSnapshotSampler;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationMath;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public final class ClientTimeDilationTicker {
|
||||
private static volatile List<TimeDilationFieldSnapshot> activeFields = List.of();
|
||||
private static ClientLevel activeLevel;
|
||||
private static final Map<ItemEntity, ItemSpinState> ITEM_SPIN_STATES = new WeakHashMap<>();
|
||||
private static final Map<LivingEntity, AttackAnimationState> ATTACK_ANIMATION_STATES = new WeakHashMap<>();
|
||||
private static final Map<LivingEntity, AnimationClockState> WALK_ANIMATION_STATES = new WeakHashMap<>();
|
||||
private static final Map<Entity, AnimationClockState> ANIMATION_CLOCKS = new WeakHashMap<>();
|
||||
|
||||
private ClientTimeDilationTicker() {
|
||||
}
|
||||
|
||||
public static void tick(ClientLevel level) {
|
||||
if (activeLevel != level) {
|
||||
activeLevel = level;
|
||||
activeFields = List.of();
|
||||
ITEM_SPIN_STATES.clear();
|
||||
ATTACK_ANIMATION_STATES.clear();
|
||||
WALK_ANIMATION_STATES.clear();
|
||||
ANIMATION_CLOCKS.clear();
|
||||
ContractionAfterimages.clear();
|
||||
com.craisinlord.antarchy.content.time.TimeDilationApi.clearSyncedClientRates();
|
||||
}
|
||||
ContractionAfterimages.tick(level);
|
||||
}
|
||||
|
||||
public static float dilateAnimationTime(Entity entity, float vanillaTime) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
if (rate >= TimeDilationMath.NORMAL_RATE) {
|
||||
ANIMATION_CLOCKS.remove(entity);
|
||||
return vanillaTime;
|
||||
}
|
||||
AnimationClockState state = ANIMATION_CLOCKS.computeIfAbsent(entity,
|
||||
ignored -> new AnimationClockState(vanillaTime));
|
||||
float delta = vanillaTime - state.lastVanillaTime;
|
||||
if (delta >= 0.0F) {
|
||||
state.temporalTime += delta * (float) rate;
|
||||
}
|
||||
state.lastVanillaTime = vanillaTime;
|
||||
return state.temporalTime;
|
||||
}
|
||||
|
||||
public static float dilateAttackAnimation(LivingEntity entity, float partialTick, float vanillaAnimation) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
if (rate >= TimeDilationMath.NORMAL_RATE) {
|
||||
ATTACK_ANIMATION_STATES.remove(entity);
|
||||
return vanillaAnimation;
|
||||
}
|
||||
AttackAnimationState state = ATTACK_ANIMATION_STATES.computeIfAbsent(
|
||||
entity, ignored -> new AttackAnimationState(entity.tickCount, vanillaAnimation)
|
||||
);
|
||||
if (state.lastTick != entity.tickCount) {
|
||||
state.previous = state.current;
|
||||
state.current += (vanillaAnimation - state.current) * (float) rate;
|
||||
state.lastTick = entity.tickCount;
|
||||
}
|
||||
return state.previous + (state.current - state.previous) * partialTick;
|
||||
}
|
||||
|
||||
public static float dilateRotation(LivingEntity entity, float previous, float current, float partialTick) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
if (rate >= TimeDilationMath.NORMAL_RATE) {
|
||||
return Mth.rotLerp(partialTick, previous, current);
|
||||
}
|
||||
return previous + Mth.wrapDegrees(current - previous) * partialTick * (float) rate;
|
||||
}
|
||||
|
||||
public static float dilatePitch(LivingEntity entity, float previous, float current, float partialTick) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
if (rate >= TimeDilationMath.NORMAL_RATE) {
|
||||
return Mth.lerp(partialTick, previous, current);
|
||||
}
|
||||
return previous + (current - previous) * partialTick * (float) rate;
|
||||
}
|
||||
|
||||
public static float dilateWalkAmount(LivingEntity entity, float amount) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
return rate >= TimeDilationMath.NORMAL_RATE ? amount : amount * (float) rate;
|
||||
}
|
||||
|
||||
public static float dilateWalkPosition(LivingEntity entity, float vanillaPosition) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(entity);
|
||||
if (Math.abs(rate - TimeDilationMath.NORMAL_RATE) < 0.001D) {
|
||||
WALK_ANIMATION_STATES.remove(entity);
|
||||
return vanillaPosition;
|
||||
}
|
||||
AnimationClockState state = WALK_ANIMATION_STATES.computeIfAbsent(entity,
|
||||
ignored -> new AnimationClockState(vanillaPosition));
|
||||
float delta = vanillaPosition - state.lastVanillaTime;
|
||||
if (delta >= 0.0F) {
|
||||
state.temporalTime += delta * (float) rate;
|
||||
}
|
||||
state.lastVanillaTime = vanillaPosition;
|
||||
return state.temporalTime;
|
||||
}
|
||||
|
||||
public static float dilateItemSpin(ItemEntity item, float vanillaSpin) {
|
||||
double rate = com.craisinlord.antarchy.content.time.TimeDilationApi.getRate(item);
|
||||
if (rate >= TimeDilationMath.NORMAL_RATE) {
|
||||
ITEM_SPIN_STATES.remove(item);
|
||||
return vanillaSpin;
|
||||
}
|
||||
ItemSpinState state = ITEM_SPIN_STATES.computeIfAbsent(item, ignored -> new ItemSpinState(vanillaSpin));
|
||||
float rawDelta = vanillaSpin - state.lastVanillaSpin;
|
||||
state.lastVanillaSpin = vanillaSpin;
|
||||
state.temporalSpin += rawDelta * (float) rate;
|
||||
return state.temporalSpin;
|
||||
}
|
||||
|
||||
private static final class ItemSpinState {
|
||||
private float lastVanillaSpin;
|
||||
private float temporalSpin;
|
||||
|
||||
private ItemSpinState(float initialSpin) {
|
||||
this.lastVanillaSpin = initialSpin;
|
||||
this.temporalSpin = initialSpin;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AttackAnimationState {
|
||||
private int lastTick;
|
||||
private float previous;
|
||||
private float current;
|
||||
|
||||
private AttackAnimationState(int tick, float initial) {
|
||||
this.lastTick = tick;
|
||||
this.previous = initial;
|
||||
this.current = initial;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AnimationClockState {
|
||||
private float lastVanillaTime;
|
||||
private float temporalTime;
|
||||
|
||||
private AnimationClockState(float initialTime) {
|
||||
this.lastVanillaTime = initialTime;
|
||||
this.temporalTime = initialTime;
|
||||
}
|
||||
}
|
||||
|
||||
public static double rateAt(double x, double y, double z) {
|
||||
List<TimeDilationFieldSnapshot> fields = activeFields;
|
||||
if (fields.isEmpty()) {
|
||||
return TimeDilationMath.NORMAL_RATE;
|
||||
}
|
||||
return TimeDilationFieldSnapshotSampler.sample(fields, x, y, z);
|
||||
}
|
||||
|
||||
public static void applyFields(List<TimeDilationFieldSnapshot> fields) {
|
||||
activeFields = List.copyOf(fields);
|
||||
}
|
||||
|
||||
public static boolean hasActiveDilation() {
|
||||
return !activeFields.isEmpty()
|
||||
|| com.craisinlord.antarchy.content.time.TimeDilationApi.hasSyncedClientRates();
|
||||
}
|
||||
}
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectHooks;
|
||||
import com.craisinlord.antarchy.content.item.TemporalTunerItem;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationApi;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public final class ContractionAfterimages {
|
||||
public static final int MAX_SAMPLES = 10;
|
||||
public static final int SAMPLE_LIFETIME_TICKS = 13;
|
||||
public static final int DEFAULT_COLOR = 0xFFD35A;
|
||||
private static final List<Predicate<LivingEntity>> ACTIVATORS = new CopyOnWriteArrayList<>();
|
||||
private static final List<Function<LivingEntity, Integer>> COLOR_PROVIDERS = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static final Map<LivingEntity, Deque<Sample>> HISTORY = new WeakHashMap<>();
|
||||
|
||||
private ContractionAfterimages() {
|
||||
}
|
||||
|
||||
public static void tick(ClientLevel level) {
|
||||
int now = (int) (level.getGameTime() & 0x7fffffffL);
|
||||
|
||||
Iterator<Map.Entry<LivingEntity, Deque<Sample>>> iterator = HISTORY.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
LivingEntity tracked = iterator.next().getKey();
|
||||
if (tracked == null || tracked.isRemoved() || !tracked.isAlive() || !isActive(tracked)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void observe(LivingEntity living) {
|
||||
if (!isActive(living)) {
|
||||
return;
|
||||
}
|
||||
int now = (int) (living.level().getGameTime() & 0x7fffffffL);
|
||||
Deque<Sample> samples = HISTORY.computeIfAbsent(living, ignored -> new ArrayDeque<>());
|
||||
samples.addFirst(new Sample(living, now));
|
||||
while (samples.size() > MAX_SAMPLES) {
|
||||
samples.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
public static Deque<Sample> samples(LivingEntity entity) {
|
||||
return HISTORY.get(entity);
|
||||
}
|
||||
|
||||
public static void addActivator(Predicate<LivingEntity> activator) {
|
||||
ACTIVATORS.add(activator);
|
||||
}
|
||||
|
||||
public static void addColorProvider(Function<LivingEntity, Integer> provider) {
|
||||
COLOR_PROVIDERS.add(provider);
|
||||
}
|
||||
|
||||
public static int colorFor(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity living)) {
|
||||
return DEFAULT_COLOR;
|
||||
}
|
||||
for (Function<LivingEntity, Integer> provider : COLOR_PROVIDERS) {
|
||||
Integer color = provider.apply(living);
|
||||
if (color != null) {
|
||||
return color & 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
return DEFAULT_COLOR;
|
||||
}
|
||||
|
||||
public static boolean isActive(LivingEntity living) {
|
||||
Holder<MobEffect> holder = RoyalEffectHooks.contractedHolder();
|
||||
boolean contracted = holder != null && living.hasEffect(holder);
|
||||
boolean tuned = living instanceof net.minecraft.world.entity.player.Player player
|
||||
&& TemporalTunerItem.isAvailable(player)
|
||||
&& TimeDilationApi.getRate(living) > 1.0D;
|
||||
if (living.isInvisible()) {
|
||||
return false;
|
||||
}
|
||||
if (contracted || tuned) {
|
||||
return true;
|
||||
}
|
||||
for (Predicate<LivingEntity> activator : ACTIVATORS) {
|
||||
if (activator.test(living)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float fade(Sample sample, int now) {
|
||||
float elapsed = now - sample.recordedTick;
|
||||
return Math.max(0.0F, 1.0F - elapsed / SAMPLE_LIFETIME_TICKS);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
HISTORY.clear();
|
||||
}
|
||||
|
||||
public static final class Sample {
|
||||
public final double x;
|
||||
public final double y;
|
||||
public final double z;
|
||||
public final float bodyYaw;
|
||||
public final float headYaw;
|
||||
public final float xRot;
|
||||
public final float limbPos;
|
||||
public final float limbSpeed;
|
||||
public final float ageInTicks;
|
||||
public final int recordedTick;
|
||||
|
||||
Sample(LivingEntity entity, int recordedTick) {
|
||||
this.x = entity.getX();
|
||||
this.y = entity.getY();
|
||||
this.z = entity.getZ();
|
||||
this.bodyYaw = entity.yBodyRot;
|
||||
this.headYaw = entity.getYHeadRot();
|
||||
this.xRot = entity.getXRot();
|
||||
this.limbPos = entity.walkAnimation.position();
|
||||
this.limbSpeed = Math.min(entity.walkAnimation.speed(), 1.0F);
|
||||
this.ageInTicks = entity.tickCount;
|
||||
this.recordedTick = recordedTick;
|
||||
}
|
||||
}
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.network.PortalGunTransitPayload;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransitMath;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class PortalGunClientTransit {
|
||||
private static long cooldownUntil;
|
||||
|
||||
private PortalGunClientTransit() {
|
||||
}
|
||||
|
||||
public static void afterLocalMove(LocalPlayer player, AABB startBox, Vec3 velocity) {
|
||||
if (player.level() == null || !player.isAlive() || player.isPassenger() || player.isSpectator()) {
|
||||
return;
|
||||
}
|
||||
long gameTime = player.level().getGameTime();
|
||||
if (gameTime < cooldownUntil && cooldownUntil - gameTime <= PortalGunPortalEntity.TELEPORT_COOLDOWN_TICKS) {
|
||||
return;
|
||||
}
|
||||
AABB currentBox = player.getBoundingBox();
|
||||
if (velocity.lengthSqr() <= 1.0E-12D && startBox.getCenter().distanceToSqr(currentBox.getCenter()) <= 1.0E-10D) {
|
||||
return;
|
||||
}
|
||||
ClientPacketListener connection = Minecraft.getInstance().getConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
Vec3 crossingVelocity = AntarchyGravityApi.isGravityInverted(player)
|
||||
? PortalGunTransitMath.entityVelocityToWorld(player, velocity)
|
||||
: velocity;
|
||||
for (PortalGunPortalEntity portal : PortalGunPortalEntity.findPortalsNearBounds(player.level(), startBox.minmax(currentBox).expandTowards(crossingVelocity).inflate(1.0D))) {
|
||||
PortalGunPortalEntity linked = portal.getLinkedPortal();
|
||||
if (linked == null || !linked.isAlive()) {
|
||||
continue;
|
||||
}
|
||||
if (portal.resolveCrossing(player, startBox, currentBox, crossingVelocity) == null) {
|
||||
continue;
|
||||
}
|
||||
Vec3 look = player.getLookAngle();
|
||||
connection.send(new ServerboundCustomPayloadPacket(new PortalGunTransitPayload(
|
||||
portal.getId(), PortalGunTransitMath.entityPosition(startBox, player), player.position(), velocity)));
|
||||
PortalGunPortalEntity.PortalTransit transit = portal.computeTransit(player, linked, currentBox, velocity, look);
|
||||
Vec3 rollLook = AntarchyGravityApi.isGravityInverted(player)
|
||||
? PortalGunTransitMath.entityVelocityToWorld(player, look)
|
||||
: look;
|
||||
PortalGunRollClientState.onTransit(portal, linked, rollLook);
|
||||
apply(player, transit);
|
||||
cooldownUntil = gameTime + PortalGunPortalEntity.TELEPORT_COOLDOWN_TICKS;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void apply(LocalPlayer player, PortalGunPortalEntity.PortalTransit transit) {
|
||||
Vec3 position = transit.position();
|
||||
float yaw = PortalGunTransformUtil.yawFromLook(transit.look());
|
||||
float pitch = PortalGunTransformUtil.pitchFromLook(transit.look());
|
||||
player.setPos(position.x, position.y, position.z);
|
||||
player.xo = position.x;
|
||||
player.yo = position.y;
|
||||
player.zo = position.z;
|
||||
player.xOld = position.x;
|
||||
player.yOld = position.y;
|
||||
player.zOld = position.z;
|
||||
player.setYRot(yaw);
|
||||
player.setXRot(pitch);
|
||||
player.yRotO = yaw;
|
||||
player.xRotO = pitch;
|
||||
player.setYHeadRot(yaw);
|
||||
player.yHeadRotO = yaw;
|
||||
player.setYBodyRot(yaw);
|
||||
player.yBodyRotO = yaw;
|
||||
player.setDeltaMovement(transit.velocity());
|
||||
Vec3 fallVelocity = PortalGunTransitMath.entityVelocityToWorld(player, transit.velocity());
|
||||
player.fallDistance = PortalGunTransitMath.exitFallDistance(player.fallDistance, fallVelocity, player);
|
||||
player.setOnGround(false);
|
||||
player.horizontalCollision = false;
|
||||
player.verticalCollision = false;
|
||||
player.verticalCollisionBelow = false;
|
||||
player.setPortalCooldown(PortalGunPortalEntity.TELEPORT_COOLDOWN_TICKS);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -79,8 +79,8 @@ public final class PortalGunCrosshairRenderer {
|
||||
long gameTime = level.getGameTime();
|
||||
if (cachedLevel != level || cachedGameTime != gameTime || !gunId.equals(cachedGunId)) {
|
||||
Set<PortalGunPortalEntity.PortalSide> portals = EnumSet.noneOf(PortalGunPortalEntity.PortalSide.class);
|
||||
for (PortalGunPortalEntity portal : com.craisinlord.antarchy.content.portalgun.PortalGunPortalRegistry.all(level)) {
|
||||
if (portal.isAlive() && gunId.equals(portal.getGunId())) {
|
||||
for (com.craisinlord.anthology.portal.PortalEntity entry : com.craisinlord.anthology.portal.PortalRegistry.all(level)) {
|
||||
if (entry instanceof PortalGunPortalEntity portal && portal.isAlive() && gunId.equals(portal.getGunId())) {
|
||||
portals.add(portal.getPortalSide());
|
||||
}
|
||||
}
|
||||
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class PortalGunEntityTransformationStack {
|
||||
private final Entity entity;
|
||||
private final Deque<EntityTransformation> stack = new ArrayDeque<>();
|
||||
|
||||
public PortalGunEntityTransformationStack(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public void push() {
|
||||
this.stack.push(EntityTransformation.capture(this.entity));
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
if (!this.stack.isEmpty()) {
|
||||
this.stack.pop().restore(this.entity);
|
||||
}
|
||||
}
|
||||
|
||||
public Vec3 moveEntity(PortalGunPortalEntity sourcePortal, PortalGunPortalEntity destinationPortal, float partialTick) {
|
||||
double eyeHeight = this.entity.getEyeHeight();
|
||||
Vec3 interpolatedEye = new Vec3(
|
||||
net.minecraft.util.Mth.lerp(partialTick, this.entity.xo, this.entity.getX()),
|
||||
net.minecraft.util.Mth.lerp(partialTick, this.entity.yo, this.entity.getY()) + eyeHeight,
|
||||
net.minecraft.util.Mth.lerp(partialTick, this.entity.zo, this.entity.getZ())
|
||||
);
|
||||
Vec3 previousEye = new Vec3(this.entity.xo, this.entity.yo + eyeHeight, this.entity.zo);
|
||||
Vec3 transformedEye = destinationPortal.position().add(PortalGunTransformUtil.transformPosition(sourcePortal, destinationPortal, interpolatedEye.subtract(sourcePortal.position())));
|
||||
Vec3 transformedPreviousEye = destinationPortal.position().add(PortalGunTransformUtil.transformPosition(sourcePortal, destinationPortal, previousEye.subtract(sourcePortal.position())));
|
||||
Vec3 transformed = transformedEye.subtract(0.0D, eyeHeight, 0.0D);
|
||||
Vec3 transformedPrevious = transformedPreviousEye.subtract(0.0D, eyeHeight, 0.0D);
|
||||
Vec3 look = PortalGunTransformUtil.transformVector(sourcePortal, destinationPortal, this.entity.getLookAngle()).normalize();
|
||||
Vec3 previousLook = PortalGunTransformUtil.transformVector(
|
||||
sourcePortal,
|
||||
destinationPortal,
|
||||
Vec3.directionFromRotation(this.entity.xRotO, this.entity.yRotO)
|
||||
).normalize();
|
||||
Vec3 velocity = PortalGunTransformUtil.transformVector(sourcePortal, destinationPortal, this.entity.getDeltaMovement());
|
||||
float yaw = PortalGunTransformUtil.yawFromLook(look);
|
||||
float pitch = PortalGunTransformUtil.pitchFromLook(look);
|
||||
float previousYaw = PortalGunTransformUtil.yawFromLook(previousLook);
|
||||
float previousPitch = PortalGunTransformUtil.pitchFromLook(previousLook);
|
||||
float yawDelta = net.minecraft.util.Mth.wrapDegrees(yaw - this.entity.getYRot());
|
||||
this.entity.setPos(transformed.x, transformed.y, transformed.z);
|
||||
this.entity.xo = transformedPrevious.x;
|
||||
this.entity.yo = transformedPrevious.y;
|
||||
this.entity.zo = transformedPrevious.z;
|
||||
this.entity.setYRot(yaw);
|
||||
this.entity.setXRot(pitch);
|
||||
this.entity.yRotO = previousYaw;
|
||||
this.entity.xRotO = previousPitch;
|
||||
this.entity.setDeltaMovement(velocity);
|
||||
if (this.entity instanceof LivingEntity living) {
|
||||
living.setYHeadRot(living.getYHeadRot() + yawDelta);
|
||||
living.setYBodyRot(living.yBodyRot + yawDelta);
|
||||
living.yHeadRotO += yawDelta;
|
||||
living.yBodyRotO += yawDelta;
|
||||
}
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
while (!this.stack.isEmpty()) {
|
||||
this.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private record EntityTransformation(
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double xo,
|
||||
double yo,
|
||||
double zo,
|
||||
float yRot,
|
||||
float xRot,
|
||||
float yRotO,
|
||||
float xRotO,
|
||||
float yHeadRot,
|
||||
float yHeadRotO,
|
||||
float yBodyRot,
|
||||
float yBodyRotO,
|
||||
Vec3 deltaMovement
|
||||
) {
|
||||
private static EntityTransformation capture(Entity entity) {
|
||||
float yHeadRot = entity instanceof LivingEntity living ? living.getYHeadRot() : entity.getYRot();
|
||||
float yHeadRotO = entity instanceof LivingEntity living ? living.yHeadRotO : entity.yRotO;
|
||||
float yBodyRot = entity instanceof LivingEntity living ? living.yBodyRot : entity.getYRot();
|
||||
float yBodyRotO = entity instanceof LivingEntity living ? living.yBodyRotO : entity.yRotO;
|
||||
return new EntityTransformation(entity.getX(), entity.getY(), entity.getZ(), entity.xo, entity.yo, entity.zo, entity.getYRot(), entity.getXRot(), entity.yRotO, entity.xRotO, yHeadRot, yHeadRotO, yBodyRot, yBodyRotO, entity.getDeltaMovement());
|
||||
}
|
||||
|
||||
private void restore(Entity entity) {
|
||||
entity.setPos(this.x, this.y, this.z);
|
||||
entity.xo = this.xo;
|
||||
entity.yo = this.yo;
|
||||
entity.zo = this.zo;
|
||||
entity.setYRot(this.yRot);
|
||||
entity.setXRot(this.xRot);
|
||||
entity.yRotO = this.yRotO;
|
||||
entity.xRotO = this.xRotO;
|
||||
entity.setDeltaMovement(this.deltaMovement);
|
||||
if (entity instanceof LivingEntity living) {
|
||||
living.setYHeadRot(this.yHeadRot);
|
||||
living.yHeadRotO = this.yHeadRotO;
|
||||
living.setYBodyRot(this.yBodyRot);
|
||||
living.yBodyRotO = this.yBodyRotO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunWorldPortalShape;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunApertureCuller;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public final class PortalGunPortalRenderState {
|
||||
private static final ThreadLocal<Deque<PortalGunWorldPortalShape>> ACTIVE_DESTINATION_SHAPES = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
private static final ThreadLocal<Deque<PortalGunWorldPortalShape>> ACTIVE_SOURCE_SHAPES = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
private static final ThreadLocal<Deque<PortalRenderContext>> ACTIVE_CONTEXTS = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
private static final ThreadLocal<Deque<PortalGunApertureCuller>> ACTIVE_CULLERS = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
private static final ThreadLocal<Integer> RENDER_ALL_DEPTH = ThreadLocal.withInitial(() -> 0);
|
||||
|
||||
private PortalGunPortalRenderState() {
|
||||
}
|
||||
|
||||
public static void pushPortalView(PortalGunWorldPortalShape sourceShape, PortalGunWorldPortalShape destinationShape, boolean renderAll) {
|
||||
ACTIVE_SOURCE_SHAPES.get().push(sourceShape);
|
||||
ACTIVE_DESTINATION_SHAPES.get().push(destinationShape);
|
||||
if (renderAll) {
|
||||
RENDER_ALL_DEPTH.set(RENDER_ALL_DEPTH.get() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void pushPortalView(PortalRenderContext context) {
|
||||
ACTIVE_CONTEXTS.get().push(context);
|
||||
ACTIVE_CULLERS.get().push(PortalGunApertureCuller.create(context.destinationShape(), context.cameraPos()));
|
||||
pushPortalView(context.sourceShape(), context.destinationShape(), context.renderAll());
|
||||
}
|
||||
|
||||
public static void popPortalView(boolean renderAll) {
|
||||
Deque<PortalGunWorldPortalShape> sourceShapes = ACTIVE_SOURCE_SHAPES.get();
|
||||
if (!sourceShapes.isEmpty()) {
|
||||
sourceShapes.pop();
|
||||
}
|
||||
if (sourceShapes.isEmpty()) {
|
||||
ACTIVE_SOURCE_SHAPES.remove();
|
||||
}
|
||||
Deque<PortalGunWorldPortalShape> destinationShapes = ACTIVE_DESTINATION_SHAPES.get();
|
||||
if (!destinationShapes.isEmpty()) {
|
||||
destinationShapes.pop();
|
||||
}
|
||||
if (destinationShapes.isEmpty()) {
|
||||
ACTIVE_DESTINATION_SHAPES.remove();
|
||||
}
|
||||
if (renderAll) {
|
||||
int depth = Math.max(0, RENDER_ALL_DEPTH.get() - 1);
|
||||
if (depth == 0) {
|
||||
RENDER_ALL_DEPTH.remove();
|
||||
} else {
|
||||
RENDER_ALL_DEPTH.set(depth);
|
||||
}
|
||||
}
|
||||
Deque<PortalRenderContext> contexts = ACTIVE_CONTEXTS.get();
|
||||
if (!contexts.isEmpty()) {
|
||||
contexts.pop();
|
||||
}
|
||||
if (contexts.isEmpty()) {
|
||||
ACTIVE_CONTEXTS.remove();
|
||||
}
|
||||
Deque<PortalGunApertureCuller> cullers = ACTIVE_CULLERS.get();
|
||||
if (!cullers.isEmpty()) {
|
||||
cullers.pop();
|
||||
}
|
||||
if (cullers.isEmpty()) {
|
||||
ACTIVE_CULLERS.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static void pushDestinationShape(PortalGunWorldPortalShape shape) {
|
||||
ACTIVE_DESTINATION_SHAPES.get().push(shape);
|
||||
}
|
||||
|
||||
public static void popDestinationShape() {
|
||||
Deque<PortalGunWorldPortalShape> shapes = ACTIVE_DESTINATION_SHAPES.get();
|
||||
if (!shapes.isEmpty()) {
|
||||
shapes.pop();
|
||||
}
|
||||
if (shapes.isEmpty()) {
|
||||
ACTIVE_DESTINATION_SHAPES.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public static PortalGunWorldPortalShape getDestinationShape() {
|
||||
Deque<PortalGunWorldPortalShape> shapes = ACTIVE_DESTINATION_SHAPES.get();
|
||||
return shapes.isEmpty() ? null : shapes.peek();
|
||||
}
|
||||
|
||||
public static PortalGunWorldPortalShape getSourceShape() {
|
||||
Deque<PortalGunWorldPortalShape> shapes = ACTIVE_SOURCE_SHAPES.get();
|
||||
return shapes.isEmpty() ? null : shapes.peek();
|
||||
}
|
||||
|
||||
public static PortalRenderContext getContext() {
|
||||
Deque<PortalRenderContext> contexts = ACTIVE_CONTEXTS.get();
|
||||
return contexts.isEmpty() ? null : contexts.peek();
|
||||
}
|
||||
|
||||
public static int getRenderLevel() {
|
||||
return ACTIVE_CONTEXTS.get().size();
|
||||
}
|
||||
|
||||
public static boolean renderAll() {
|
||||
return RENDER_ALL_DEPTH.get() > 0;
|
||||
}
|
||||
|
||||
public static boolean shouldRenderBounds(AABB bounds) {
|
||||
if (renderAll()) {
|
||||
return true;
|
||||
}
|
||||
PortalRenderContext context = getContext();
|
||||
if (context == null) {
|
||||
PortalGunWorldPortalShape destinationShape = getDestinationShape();
|
||||
PortalGunWorldPortalShape sourceShape = getSourceShape();
|
||||
return destinationShape == null || shouldRenderBounds(bounds, sourceShape, destinationShape, false);
|
||||
}
|
||||
if (!context.destinationShape().intersectsFront(bounds, 0.125D)) {
|
||||
return false;
|
||||
}
|
||||
Deque<PortalGunApertureCuller> cullers = ACTIVE_CULLERS.get();
|
||||
return cullers.isEmpty() || cullers.peek().intersects(bounds);
|
||||
}
|
||||
|
||||
private static boolean shouldRenderBounds(AABB bounds, PortalGunWorldPortalShape sourceShape, PortalGunWorldPortalShape destinationShape, boolean renderAll) {
|
||||
if (renderAll) {
|
||||
return true;
|
||||
}
|
||||
if (!destinationShape.intersectsFront(bounds, 0.125D)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public record PortalRenderContext(
|
||||
PortalGunWorldPortalShape sourceShape,
|
||||
PortalGunWorldPortalShape destinationShape,
|
||||
Vec3 cameraPos,
|
||||
Vec3 look,
|
||||
Vec3 up,
|
||||
Matrix4f viewMatrix,
|
||||
Matrix4f projectionMatrix,
|
||||
int renderLevel,
|
||||
boolean renderAll,
|
||||
UUID destinationId
|
||||
) {
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client;
|
||||
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class PortalGunRollClientState {
|
||||
private static final double PORTAL_QUERY_RADIUS = 12.0D;
|
||||
private static final float ROLL_DECAY = 0.85F;
|
||||
private static final float ROLL_EPSILON = 0.05F;
|
||||
private static float previousRollDegrees;
|
||||
private static float rollDegrees;
|
||||
|
||||
private PortalGunRollClientState() {
|
||||
}
|
||||
|
||||
public static float getRollDegrees() {
|
||||
return rollDegrees;
|
||||
}
|
||||
|
||||
public static float getRollDegrees(float partialTick) {
|
||||
return previousRollDegrees + (rollDegrees - previousRollDegrees) * partialTick;
|
||||
}
|
||||
|
||||
public static boolean isEntityInsidePortal(Minecraft minecraft, Entity entity) {
|
||||
if (minecraft.level == null || entity == null) {
|
||||
return false;
|
||||
}
|
||||
for (PortalGunPortalEntity portal : com.craisinlord.antarchy.content.portalgun.PortalGunPortalRegistry.near(minecraft.level, entity.getBoundingBox().inflate(PORTAL_QUERY_RADIUS))) {
|
||||
if (portal.intersectsEntityBounds(entity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCameraInsidePortal(Minecraft minecraft) {
|
||||
Entity cameraEntity = minecraft.getCameraEntity();
|
||||
return cameraEntity != null && isEntityInsidePortal(minecraft, cameraEntity);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
previousRollDegrees = 0.0F;
|
||||
rollDegrees = 0.0F;
|
||||
}
|
||||
|
||||
public static void tick(Minecraft minecraft) {
|
||||
if (minecraft.level == null || minecraft.player == null) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
previousRollDegrees = rollDegrees;
|
||||
rollDegrees *= ROLL_DECAY;
|
||||
if (Math.abs(rollDegrees) < ROLL_EPSILON) {
|
||||
rollDegrees = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public static void onTransit(PortalGunPortalEntity sourcePortal, PortalGunPortalEntity destinationPortal, Vec3 look) {
|
||||
Vec3 transformedLook = PortalGunTransformUtil.transformVector(sourcePortal, destinationPortal, look).normalize();
|
||||
Vec3 transformedUp = PortalGunTransformUtil.transformVector(sourcePortal, destinationPortal, PortalGunTransformUtil.upVectorFromLookAndRoll(look, rollDegrees)).normalize();
|
||||
rollDegrees = PortalGunTransformUtil.rollFromOrientation(transformedLook, transformedUp);
|
||||
previousRollDegrees = rollDegrees;
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.model;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class PortalGunPortalModel extends GeoModel<PortalGunPortalEntity> {
|
||||
private static final ResourceLocation BLUE_TEXTURE = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/vfx/portal_gun_portal_blue.png");
|
||||
private static final ResourceLocation ORANGE_TEXTURE = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/vfx/portal_gun_portal_orange.png");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(PortalGunPortalEntity animatable) {
|
||||
return ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "geo/portal_gun_portal.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(PortalGunPortalEntity animatable) {
|
||||
return animatable.getPortalSide() == PortalGunPortalEntity.PortalSide.BLUE ? BLUE_TEXTURE : ORANGE_TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(PortalGunPortalEntity animatable) {
|
||||
return ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "animations/portal_gun_portal.animation.json");
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
|
||||
final class IrisPortalSceneCompat {
|
||||
private static final Field PIPELINE_FIELD;
|
||||
private static final Method GET_PIPELINE_MANAGER;
|
||||
private static final Method GET_PIPELINE;
|
||||
|
||||
static {
|
||||
Field field = null;
|
||||
Method manager = null;
|
||||
Method pipeline = null;
|
||||
try {
|
||||
Class<?> iris = Class.forName("net.irisshaders.iris.Iris");
|
||||
manager = iris.getMethod("getPipelineManager");
|
||||
pipeline = manager.getReturnType().getMethod("getPipelineNullable");
|
||||
field = LevelRenderer.class.getDeclaredField("pipeline");
|
||||
field.setAccessible(true);
|
||||
} catch (ReflectiveOperationException | RuntimeException | LinkageError ignored) {
|
||||
field = null;
|
||||
}
|
||||
PIPELINE_FIELD = field;
|
||||
GET_PIPELINE_MANAGER = field == null ? null : manager;
|
||||
GET_PIPELINE = field == null ? null : pipeline;
|
||||
}
|
||||
|
||||
private IrisPortalSceneCompat() {
|
||||
}
|
||||
|
||||
static boolean begin(LevelRenderer renderer) {
|
||||
if (PIPELINE_FIELD == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (PIPELINE_FIELD.get(renderer) != null) {
|
||||
return false;
|
||||
}
|
||||
Object pipeline = GET_PIPELINE.invoke(GET_PIPELINE_MANAGER.invoke(null));
|
||||
if (pipeline == null) {
|
||||
return false;
|
||||
}
|
||||
PIPELINE_FIELD.set(renderer, pipeline);
|
||||
return true;
|
||||
} catch (ReflectiveOperationException | RuntimeException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void end(LevelRenderer renderer, boolean installed) {
|
||||
if (!installed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PIPELINE_FIELD.set(renderer, null);
|
||||
} catch (ReflectiveOperationException | RuntimeException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunWorldPortalShape;
|
||||
import com.craisinlord.anthology.portal.PortalTransforms;
|
||||
import com.craisinlord.anthology.portal.PortalShape;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
@@ -37,13 +37,13 @@ public final class PortalGunMoonViewRenderer {
|
||||
private PortalGunMoonViewRenderer() {
|
||||
}
|
||||
|
||||
public static void render(Minecraft minecraft, PortalGunWorldPortalShape source, Vec3 cameraPos, Vec3 look, Vec3 up,
|
||||
public static void render(Minecraft minecraft, PortalShape source, Vec3 cameraPos, Vec3 look, Vec3 up,
|
||||
Matrix4f rootProjection, float partialTick) {
|
||||
PortalGunWorldPortalShape exit = new PortalGunWorldPortalShape(Vec3.ZERO, EXIT_NORMAL, EXIT_UP, EXIT_NORMAL.cross(EXIT_UP),
|
||||
PortalShape exit = new PortalShape(Vec3.ZERO, EXIT_NORMAL, EXIT_UP, EXIT_NORMAL.cross(EXIT_UP),
|
||||
source.halfWidth(), source.halfHeight(), source.halfDepth());
|
||||
Vec3 moonLook = PortalGunTransformUtil.transformVector(source, exit, look).normalize();
|
||||
Vec3 moonUp = PortalGunTransformUtil.transformVector(source, exit, up).normalize();
|
||||
Matrix4f view = new Matrix4f().rotation(PortalGunTransformUtil.orientationQuaternion(moonLook, moonUp).conjugate(new Quaternionf()));
|
||||
Vec3 moonLook = PortalTransforms.transformVector(source, exit, look).normalize();
|
||||
Vec3 moonUp = PortalTransforms.transformVector(source, exit, up).normalize();
|
||||
Matrix4f view = new Matrix4f().rotation(PortalTransforms.orientationQuaternion(moonLook, moonUp).conjugate(new Quaternionf()));
|
||||
Vec3 earthDirection = new Vec3(0.0D, Math.sin(EARTH_ELEVATION), Math.cos(EARTH_ELEVATION));
|
||||
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
|
||||
+3
-100
@@ -1,108 +1,11 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.client.model.PortalGunPortalModel;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.GraphicsStatus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import com.craisinlord.anthology.portal.client.PortalEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class PortalGunPortalRenderer extends GeoEntityRenderer<PortalGunPortalEntity> {
|
||||
public class PortalGunPortalRenderer extends PortalEntityRenderer<PortalGunPortalEntity> {
|
||||
public PortalGunPortalRenderer(EntityRendererProvider.Context context) {
|
||||
super(context, new PortalGunPortalModel());
|
||||
this.shadowRadius = 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PortalGunPortalEntity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
|
||||
poseStack.pushPose();
|
||||
Matrix4f pose = poseStack.last().pose();
|
||||
float portalScale = entity.getPortalVisualScale(partialTick);
|
||||
float halfWidth = entity.getPortalWidth() * 0.5F;
|
||||
float halfHeight = entity.getPortalHeight() * 0.5F;
|
||||
ResourceLocation texture = portalTexture(entity);
|
||||
VertexConsumer consumer = bufferSource.getBuffer(RenderType.entityTranslucent(texture));
|
||||
if (isFancyPortalsEnabled()) {
|
||||
float frameV = Math.floorMod((int) ((entity.level().getGameTime() + partialTick) / 5.0F), 4) * 0.25F;
|
||||
putAnimatedPortalVertex(consumer, pose, entity, portalScale, frameV, -halfWidth, -halfHeight, 0.0F, 1.0F);
|
||||
putAnimatedPortalVertex(consumer, pose, entity, portalScale, frameV, -halfWidth, halfHeight, 0.0F, 0.0F);
|
||||
putAnimatedPortalVertex(consumer, pose, entity, portalScale, frameV, halfWidth, halfHeight, 1.0F, 0.0F);
|
||||
putAnimatedPortalVertex(consumer, pose, entity, portalScale, frameV, halfWidth, -halfHeight, 1.0F, 1.0F);
|
||||
} else {
|
||||
putPortalVertex(consumer, pose, entity, portalScale, -halfWidth, -halfHeight, 0.0F, 1.0F, true);
|
||||
putPortalVertex(consumer, pose, entity, portalScale, -halfWidth, halfHeight, 0.0F, 0.0F, true);
|
||||
putPortalVertex(consumer, pose, entity, portalScale, halfWidth, halfHeight, 1.0F, 0.0F, true);
|
||||
putPortalVertex(consumer, pose, entity, portalScale, halfWidth, -halfHeight, 1.0F, 1.0F, true);
|
||||
}
|
||||
VertexConsumer edge = bufferSource.getBuffer(RenderType.entityTranslucent(PortalGunPortalRim.texture(entity)));
|
||||
float rimWidth = halfWidth + PortalGunPortalRim.EXTRA_WIDTH;
|
||||
float rimHeight = halfHeight + PortalGunPortalRim.EXTRA_HEIGHT;
|
||||
putPortalVertex(edge, pose, entity, portalScale, -rimWidth, -rimHeight, 0.0F, 1.0F, true);
|
||||
putPortalVertex(edge, pose, entity, portalScale, -rimWidth, rimHeight, 0.0F, 0.0F, true);
|
||||
putPortalVertex(edge, pose, entity, portalScale, rimWidth, rimHeight, 1.0F, 0.0F, true);
|
||||
putPortalVertex(edge, pose, entity, portalScale, rimWidth, -rimHeight, 1.0F, 1.0F, true);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
private static ResourceLocation portalTexture(PortalGunPortalEntity entity) {
|
||||
return isFancyPortalsEnabled()
|
||||
? entity.getVariant().vortexTexture(entity.getPortalSide())
|
||||
: PortalGunPortalRim.texture(entity);
|
||||
}
|
||||
|
||||
private static boolean isFancyPortalsEnabled() {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
return AntarchySettings.portalGunFancyPortals()
|
||||
&& minecraft.options.graphicsMode().get() == GraphicsStatus.FANCY;
|
||||
}
|
||||
|
||||
private static void putAnimatedPortalVertex(VertexConsumer consumer, Matrix4f pose, PortalGunPortalEntity entity, float portalScale, float frameV, float horizontal, float vertical, float u, float v) {
|
||||
Vec3 position = entity.getWidthVec().normalize().scale(horizontal * portalScale)
|
||||
.add(entity.getUpVec().normalize().scale(vertical * portalScale))
|
||||
.add(entity.getNormalVec().normalize().scale(0.03125D));
|
||||
consumer.addVertex(pose, (float) position.x, (float) position.y, (float) position.z)
|
||||
.setColor(255, 255, 255, 210)
|
||||
.setUv(u, frameV + v * 0.25F)
|
||||
.setOverlay(OverlayTexture.NO_OVERLAY)
|
||||
.setLight(LightTexture.FULL_BRIGHT)
|
||||
.setNormal((float) entity.getNormalVec().x, (float) entity.getNormalVec().y, (float) entity.getNormalVec().z);
|
||||
}
|
||||
|
||||
private static void putPortalVertex(VertexConsumer consumer, Matrix4f pose, PortalGunPortalEntity entity, float portalScale, float horizontal, float vertical, float u, float v, boolean channelTint) {
|
||||
Vec3 position = entity.getWidthVec().normalize().scale(horizontal * portalScale)
|
||||
.add(entity.getUpVec().normalize().scale(vertical * portalScale))
|
||||
.add(entity.getNormalVec().normalize().scale(0.03125D));
|
||||
int color = entity.getPortalColor();
|
||||
int red = channelTint ? color >> 16 & 0xFF : 255;
|
||||
int green = channelTint ? color >> 8 & 0xFF : 255;
|
||||
int blue = channelTint ? color & 0xFF : 255;
|
||||
int alpha = channelTint ? PortalGunPortalRim.ENTITY_ALPHA : 210;
|
||||
consumer.addVertex(pose, (float) position.x, (float) position.y, (float) position.z)
|
||||
.setColor(red, green, blue, alpha)
|
||||
.setUv(u, v)
|
||||
.setOverlay(OverlayTexture.NO_OVERLAY)
|
||||
.setLight(LightTexture.FULL_BRIGHT)
|
||||
.setNormal((float) entity.getNormalVec().x, (float) entity.getNormalVec().y, (float) entity.getNormalVec().z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyRotations(PortalGunPortalEntity animatable, PoseStack poseStack, float ageInTicks, float rotationYaw, float partialTick, float nativeScale) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable RenderType getRenderType(PortalGunPortalEntity animatable, ResourceLocation texture, @Nullable MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(portalTexture(animatable));
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.item.PortalGunItem;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.MeshData;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexSorting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class PortalGunPortalRim {
|
||||
public static final float EXTRA_WIDTH = 0.0F;
|
||||
public static final float EXTRA_HEIGHT = 0.0F;
|
||||
public static final int ENTITY_ALPHA = 150;
|
||||
private static final double OVERLAY_OFFSET = 0.05D;
|
||||
private static final int HIDDEN_RIM_ALPHA = 170;
|
||||
private static final ResourceLocation BLUE_TEXTURE = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/vfx/portal_gun_portal_blue.png");
|
||||
private static final ResourceLocation ORANGE_TEXTURE = ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "textures/vfx/portal_gun_portal_orange.png");
|
||||
|
||||
private PortalGunPortalRim() {
|
||||
}
|
||||
|
||||
public static ResourceLocation texture(PortalGunPortalEntity portal) {
|
||||
return portal.getPortalSide() == PortalGunPortalEntity.PortalSide.BLUE ? BLUE_TEXTURE : ORANGE_TEXTURE;
|
||||
}
|
||||
|
||||
static void drawOverView(PortalGunPortalEntity portal, Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix, float partialTick) {
|
||||
withCameraMatrices(viewMatrix, projectionMatrix, () -> {
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
drawRims(List.of(portal), cameraPos, partialTick, ENTITY_ALPHA);
|
||||
});
|
||||
}
|
||||
|
||||
static void drawHiddenOutlines(Minecraft minecraft, Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix, float partialTick) {
|
||||
drawHiddenOutlines(minecraft, cameraPos, viewMatrix, projectionMatrix, partialTick, null);
|
||||
}
|
||||
|
||||
static void drawHiddenOutlines(Minecraft minecraft, Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix, float partialTick,
|
||||
PortalGunPortalEntity excluded) {
|
||||
if (minecraft.level == null || minecraft.player == null) {
|
||||
return;
|
||||
}
|
||||
List<PortalGunPortalEntity> ownedPortals = collectOwnedPortals(minecraft);
|
||||
if (excluded != null) {
|
||||
ownedPortals.remove(excluded);
|
||||
}
|
||||
if (ownedPortals.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
withCameraMatrices(viewMatrix, projectionMatrix, () -> {
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.depthFunc(GL11.GL_GREATER);
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
|
||||
drawRims(ownedPortals, cameraPos, partialTick, HIDDEN_RIM_ALPHA);
|
||||
});
|
||||
}
|
||||
|
||||
private static void withCameraMatrices(Matrix4f viewMatrix, Matrix4f projectionMatrix, Runnable draw) {
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
modelViewStack.pushMatrix();
|
||||
try {
|
||||
modelViewStack.set(viewMatrix);
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f(projectionMatrix), VertexSorting.DISTANCE_TO_ORIGIN);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.enableBlend();
|
||||
draw.run();
|
||||
} finally {
|
||||
RenderSystem.depthFunc(GL11.GL_LEQUAL);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<PortalGunPortalEntity> collectOwnedPortals(Minecraft minecraft) {
|
||||
Set<UUID> owners = new HashSet<>();
|
||||
Player player = minecraft.player;
|
||||
owners.add(player.getUUID());
|
||||
addGunOwner(owners, player.getMainHandItem(), player.getUUID());
|
||||
addGunOwner(owners, player.getOffhandItem(), player.getUUID());
|
||||
List<PortalGunPortalEntity> portals = new ArrayList<>();
|
||||
for (PortalGunPortalEntity portal : com.craisinlord.antarchy.content.portalgun.PortalGunPortalRegistry.all(minecraft.level)) {
|
||||
if (portal.isAlive() && owners.contains(portal.getOwnerId())) {
|
||||
portals.add(portal);
|
||||
}
|
||||
}
|
||||
return portals;
|
||||
}
|
||||
|
||||
private static void addGunOwner(Set<UUID> owners, ItemStack stack, UUID fallback) {
|
||||
if (stack.getItem() instanceof PortalGunItem) {
|
||||
UUID owner = PortalGunItem.getPortalOwnerId(stack, fallback);
|
||||
if (owner != null) {
|
||||
owners.add(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawRims(List<PortalGunPortalEntity> portals, Vec3 cameraPos, float partialTick, int alpha) {
|
||||
drawRimsWithTexture(portals, cameraPos, partialTick, alpha, BLUE_TEXTURE, PortalGunPortalEntity.PortalSide.BLUE);
|
||||
drawRimsWithTexture(portals, cameraPos, partialTick, alpha, ORANGE_TEXTURE, PortalGunPortalEntity.PortalSide.ORANGE);
|
||||
}
|
||||
|
||||
private static void drawRimsWithTexture(List<PortalGunPortalEntity> portals, Vec3 cameraPos, float partialTick, int alpha,
|
||||
ResourceLocation texture, PortalGunPortalEntity.PortalSide side) {
|
||||
BufferBuilder buffer = null;
|
||||
for (PortalGunPortalEntity portal : portals) {
|
||||
if (portal.getPortalSide() != side) {
|
||||
continue;
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
}
|
||||
addRim(buffer, portal, cameraPos, partialTick, alpha);
|
||||
}
|
||||
if (buffer == null) {
|
||||
return;
|
||||
}
|
||||
MeshData mesh = buffer.build();
|
||||
if (mesh == null) {
|
||||
return;
|
||||
}
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
BufferUploader.drawWithShader(mesh);
|
||||
}
|
||||
|
||||
private static void addRim(BufferBuilder buffer, PortalGunPortalEntity portal, Vec3 cameraPos, float partialTick, int alpha) {
|
||||
float scale = portal.getPortalVisualScale(partialTick);
|
||||
if (scale <= 0.0F) {
|
||||
return;
|
||||
}
|
||||
Vec3 right = portal.getWidthVec().normalize();
|
||||
Vec3 up = portal.getUpVec().normalize();
|
||||
Vec3 center = portal.position().add(portal.getNormalVec().normalize().scale(OVERLAY_OFFSET)).subtract(cameraPos);
|
||||
double halfWidth = (portal.getPortalWidth() * 0.5D + EXTRA_WIDTH) * scale;
|
||||
double halfHeight = (portal.getPortalHeight() * 0.5D + EXTRA_HEIGHT) * scale;
|
||||
int color = portal.getPortalColor();
|
||||
int red = color >> 16 & 0xFF;
|
||||
int green = color >> 8 & 0xFF;
|
||||
int blue = color & 0xFF;
|
||||
addVertex(buffer, center, right, up, -halfWidth, -halfHeight, 0.0F, 1.0F, red, green, blue, alpha);
|
||||
addVertex(buffer, center, right, up, -halfWidth, halfHeight, 0.0F, 0.0F, red, green, blue, alpha);
|
||||
addVertex(buffer, center, right, up, halfWidth, halfHeight, 1.0F, 0.0F, red, green, blue, alpha);
|
||||
addVertex(buffer, center, right, up, halfWidth, -halfHeight, 1.0F, 1.0F, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
private static void addVertex(BufferBuilder buffer, Vec3 center, Vec3 right, Vec3 up, double horizontal, double vertical,
|
||||
float u, float v, int red, int green, int blue, int alpha) {
|
||||
Vec3 position = center.add(right.scale(horizontal)).add(up.scale(vertical));
|
||||
buffer.addVertex((float) position.x, (float) position.y, (float) position.z)
|
||||
.setUv(u, v)
|
||||
.setColor(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
-242
@@ -1,242 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.mixins.client.LevelRendererPortalSceneInvoker;
|
||||
import com.craisinlord.antarchy.mixins.client.LevelRendererPortalViewAreaAccessor;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.MeshData;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexSorting;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class PortalGunPortalSceneRenderer {
|
||||
private static RenderBuffers portalBuffers;
|
||||
private static boolean renderingScene;
|
||||
|
||||
private PortalGunPortalSceneRenderer() {
|
||||
}
|
||||
|
||||
public static MultiBufferSource.BufferSource bufferSource() {
|
||||
if (portalBuffers == null) {
|
||||
portalBuffers = new RenderBuffers(1);
|
||||
}
|
||||
return portalBuffers.bufferSource();
|
||||
}
|
||||
|
||||
public static boolean isRenderingScene() {
|
||||
return renderingScene;
|
||||
}
|
||||
|
||||
public static void render(Minecraft minecraft, Camera camera, float partialTick, Matrix4f viewMatrix,
|
||||
Matrix4f projection, Matrix4f skyProjection, Frustum frustum,
|
||||
PortalTerrain terrain, Consumer<PoseStack> crossingEntities,
|
||||
UUID sourceId, UUID destinationId, int viewLevel) {
|
||||
LevelRenderer renderer = minecraft.levelRenderer;
|
||||
LevelRendererPortalViewAreaAccessor state = (LevelRendererPortalViewAreaAccessor) renderer;
|
||||
LevelRendererPortalSceneInvoker scene = (LevelRendererPortalSceneInvoker) renderer;
|
||||
Vec3 cameraPosition = camera.getPosition();
|
||||
double cameraX = cameraPosition.x;
|
||||
double cameraY = cameraPosition.y;
|
||||
double cameraZ = cameraPosition.z;
|
||||
|
||||
int previousRainSoundTime = state.antarchy$getRainSoundTime();
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
float previousFogStart = RenderSystem.getShaderFogStart();
|
||||
float previousFogEnd = RenderSystem.getShaderFogEnd();
|
||||
float[] previousFogColor = RenderSystem.getShaderFogColor().clone();
|
||||
FogShape previousFogShape = RenderSystem.getShaderFogShape();
|
||||
Camera previousBlockEntityCamera = minecraft.getBlockEntityRenderDispatcher().camera;
|
||||
modelViewStack.pushMatrix();
|
||||
modelViewStack.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
renderingScene = true;
|
||||
boolean irisPipelineInstalled = IrisPortalSceneCompat.begin(renderer);
|
||||
terrain.begin(minecraft);
|
||||
try {
|
||||
float renderDistance = minecraft.gameRenderer.getRenderDistance();
|
||||
BlockPos cameraBlockPos = BlockPos.containing(cameraX, cameraY, cameraZ);
|
||||
boolean foggy = minecraft.level.effects().isFoggyAt(cameraBlockPos.getX(), cameraBlockPos.getY())
|
||||
|| minecraft.gui.getBossOverlay().shouldCreateWorldFog();
|
||||
|
||||
{
|
||||
RenderSystem.setShaderGameTime(minecraft.level.getGameTime(), partialTick);
|
||||
minecraft.getBlockEntityRenderDispatcher().prepare(minecraft.level, camera, minecraft.hitResult);
|
||||
minecraft.getEntityRenderDispatcher().prepare(minecraft.level, camera, minecraft.crosshairPickEntity);
|
||||
FogRenderer.setupColor(camera, partialTick, minecraft.level, minecraft.options.getEffectiveRenderDistance(),
|
||||
minecraft.gameRenderer.getDarkenWorldAmount(partialTick));
|
||||
FogRenderer.levelFogColor();
|
||||
fillBackground(RenderSystem.getShaderFogColor());
|
||||
RenderSystem.setProjectionMatrix(skyProjection, VertexSorting.DISTANCE_TO_ORIGIN);
|
||||
FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, foggy, partialTick);
|
||||
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||
if (irisPipelineInstalled || PortalGunPortalSkyQueries.shouldRenderSky(sourceId, destinationId, viewLevel)) {
|
||||
renderer.renderSky(viewMatrix, skyProjection, partialTick, camera, foggy,
|
||||
() -> FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, foggy, partialTick));
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.setProjectionMatrix(projection, VertexSorting.DISTANCE_TO_ORIGIN);
|
||||
FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_TERRAIN, Math.max(renderDistance, 32.0F), foggy, partialTick);
|
||||
{
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(true);
|
||||
terrain.drawLayer(minecraft, RenderType.solid(), cameraPosition, viewMatrix, projection);
|
||||
terrain.drawLayer(minecraft, RenderType.cutoutMipped(), cameraPosition, viewMatrix, projection);
|
||||
terrain.drawLayer(minecraft, RenderType.cutout(), cameraPosition, viewMatrix, projection);
|
||||
}
|
||||
|
||||
if (minecraft.level.effects().constantAmbientLight()) {
|
||||
Lighting.setupNetherLevel();
|
||||
} else {
|
||||
Lighting.setupLevel();
|
||||
}
|
||||
modelViewStack.pushMatrix();
|
||||
modelViewStack.mul(viewMatrix);
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
PoseStack poseStack = new PoseStack();
|
||||
MultiBufferSource.BufferSource buffers = bufferSource();
|
||||
try {
|
||||
{
|
||||
for (Entity entity : minecraft.level.entitiesForRendering()) {
|
||||
if (!minecraft.getEntityRenderDispatcher().shouldRender(entity, frustum, cameraX, cameraY, cameraZ)
|
||||
&& !entity.hasIndirectPassenger(minecraft.player)) {
|
||||
continue;
|
||||
}
|
||||
if (entity instanceof PortalGunPortalEntity portal && !portal.shouldRenderFront(cameraPosition)) {
|
||||
continue;
|
||||
}
|
||||
if (entity == camera.getEntity()
|
||||
&& entity.getBoundingBox().inflate(0.1D).contains(cameraPosition)
|
||||
&& (!(entity instanceof LivingEntity living) || !living.isSleeping())) {
|
||||
continue;
|
||||
}
|
||||
scene.antarchy$renderPortalEntity(entity, cameraX, cameraY, cameraZ, partialTick, poseStack, buffers);
|
||||
}
|
||||
crossingEntities.accept(poseStack);
|
||||
}
|
||||
buffers.endBatch();
|
||||
|
||||
{
|
||||
terrain.forEachBlockEntity(minecraft, frustum, blockEntity ->
|
||||
renderBlockEntity(minecraft, blockEntity, cameraX, cameraY, cameraZ, partialTick, poseStack, buffers));
|
||||
}
|
||||
buffers.endBatch();
|
||||
if (!irisPipelineInstalled) {
|
||||
PortalGunPortalSkyQueries.querySkyVisibility(sourceId, destinationId, viewLevel);
|
||||
}
|
||||
|
||||
{
|
||||
terrain.drawLayer(minecraft, RenderType.translucent(), cameraPosition, viewMatrix, projection);
|
||||
buffers.endBatch();
|
||||
terrain.drawLayer(minecraft, RenderType.tripwire(), cameraPosition, viewMatrix, projection);
|
||||
minecraft.particleEngine.render(minecraft.gameRenderer.lightTexture(), camera, partialTick);
|
||||
}
|
||||
|
||||
{
|
||||
RenderSystem.depthMask(false);
|
||||
scene.antarchy$renderPortalWeather(minecraft.gameRenderer.lightTexture(), partialTick, cameraX, cameraY, cameraZ);
|
||||
scene.antarchy$renderPortalWorldBorder(camera);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
buffers.endBatch();
|
||||
} finally {
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
renderingScene = false;
|
||||
IrisPortalSceneCompat.end(renderer, irisPipelineInstalled);
|
||||
terrain.end(minecraft);
|
||||
state.antarchy$setRainSoundTime(previousRainSoundTime);
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
RenderSystem.setShaderFogStart(previousFogStart);
|
||||
RenderSystem.setShaderFogEnd(previousFogEnd);
|
||||
RenderSystem.setShaderFogColor(previousFogColor[0], previousFogColor[1], previousFogColor[2], previousFogColor[3]);
|
||||
RenderSystem.setShaderFogShape(previousFogShape);
|
||||
if (previousBlockEntityCamera != null) {
|
||||
minecraft.getBlockEntityRenderDispatcher().prepare(minecraft.level, previousBlockEntityCamera, minecraft.hitResult);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillBackground(float[] fogColor) {
|
||||
int previousDepthFunction = GL11.glGetInteger(GL11.GL_DEPTH_FUNC);
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
BufferBuilder buffer = Tesselator.getInstance().begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION);
|
||||
buffer.addVertex(-1.0F, -1.0F, 0.99999F);
|
||||
buffer.addVertex(3.0F, -1.0F, 0.99999F);
|
||||
buffer.addVertex(-1.0F, 3.0F, 0.99999F);
|
||||
MeshData mesh = buffer.build();
|
||||
try {
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableCull();
|
||||
GL11.glDepthFunc(GL11.GL_ALWAYS);
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f(), previousSorting);
|
||||
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||
RenderSystem.setShaderColor(fogColor[0], fogColor[1], fogColor[2], 1.0F);
|
||||
if (mesh != null) {
|
||||
BufferUploader.drawWithShader(mesh);
|
||||
}
|
||||
} finally {
|
||||
GL11.glDepthFunc(previousDepthFunction);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
RenderSystem.enableCull();
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderBlockEntity(Minecraft minecraft, BlockEntity blockEntity, double cameraX, double cameraY, double cameraZ,
|
||||
float partialTick, PoseStack poseStack, MultiBufferSource.BufferSource buffers) {
|
||||
if (!blockEntity.hasLevel() || !blockEntity.getType().isValid(blockEntity.getBlockState())) {
|
||||
return;
|
||||
}
|
||||
BlockPos pos = blockEntity.getBlockPos();
|
||||
poseStack.pushPose();
|
||||
try {
|
||||
poseStack.translate(pos.getX() - cameraX, pos.getY() - cameraY, pos.getZ() - cameraZ);
|
||||
minecraft.getBlockEntityRenderDispatcher().render(blockEntity, partialTick, poseStack, buffers);
|
||||
} finally {
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
-165
@@ -1,165 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.mixins.client.LevelRendererPortalViewAreaAccessor;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.SectionOcclusionGraph;
|
||||
import net.minecraft.client.renderer.ViewArea;
|
||||
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public final class PortalGunPortalSectionViews {
|
||||
private static final int MAX_VIEWS = 8;
|
||||
private static final double SEED_OFFSET = 0.5D;
|
||||
private static final LinkedHashMap<UUID, View> VIEWS = new LinkedHashMap<>(8, 0.75F, true);
|
||||
private static volatile SectionOcclusionGraph[] graphs = new SectionOcclusionGraph[0];
|
||||
private static ViewArea ownerArea;
|
||||
private static int mainSectionX = Integer.MIN_VALUE;
|
||||
private static int mainSectionY = Integer.MIN_VALUE;
|
||||
private static int mainSectionZ = Integer.MIN_VALUE;
|
||||
|
||||
private PortalGunPortalSectionViews() {
|
||||
}
|
||||
|
||||
public static boolean canView(Minecraft minecraft, Vec3 exitCenter) {
|
||||
ViewArea area = ((LevelRendererPortalViewAreaAccessor) minecraft.levelRenderer).antarchy$getViewArea();
|
||||
if (area == null) {
|
||||
return false;
|
||||
}
|
||||
LevelRendererPortalViewAreaAccessor accessor = (LevelRendererPortalViewAreaAccessor) minecraft.levelRenderer;
|
||||
int limit = area.getViewDistance() - 1;
|
||||
return Math.abs(SectionPos.posToSectionCoord(exitCenter.x) - accessor.antarchy$getLastCameraSectionX()) <= limit
|
||||
&& Math.abs(SectionPos.posToSectionCoord(exitCenter.z) - accessor.antarchy$getLastCameraSectionZ()) <= limit;
|
||||
}
|
||||
|
||||
public static View prepare(Minecraft minecraft, UUID exitId, Vec3 exitCenter, Vec3 exitNormal, Frustum frustum) {
|
||||
LevelRendererPortalViewAreaAccessor accessor = (LevelRendererPortalViewAreaAccessor) minecraft.levelRenderer;
|
||||
ViewArea area = accessor.antarchy$getViewArea();
|
||||
if (area != ownerArea) {
|
||||
clear();
|
||||
ownerArea = area;
|
||||
}
|
||||
int sectionX = accessor.antarchy$getLastCameraSectionX();
|
||||
int sectionY = accessor.antarchy$getLastCameraSectionY();
|
||||
int sectionZ = accessor.antarchy$getLastCameraSectionZ();
|
||||
if (sectionX != mainSectionX || sectionY != mainSectionY || sectionZ != mainSectionZ) {
|
||||
mainSectionX = sectionX;
|
||||
mainSectionY = sectionY;
|
||||
mainSectionZ = sectionZ;
|
||||
for (View view : VIEWS.values()) {
|
||||
view.graph.invalidate();
|
||||
}
|
||||
}
|
||||
View view = VIEWS.get(exitId);
|
||||
if (view == null) {
|
||||
view = new View(area);
|
||||
VIEWS.put(exitId, view);
|
||||
trim();
|
||||
publishGraphs();
|
||||
}
|
||||
Vec3 seed = exitCenter.add(exitNormal.normalize().scale(SEED_OFFSET));
|
||||
if (!seed.equals(view.seed)) {
|
||||
view.seed = seed;
|
||||
view.seedCamera = new SeedCamera(seed);
|
||||
view.updateFrustum = centredFrustum(seed);
|
||||
view.graph.invalidate();
|
||||
}
|
||||
view.partialUpdates.clear();
|
||||
view.graph.update(minecraft.smartCull, view.seedCamera, view.updateFrustum(), view.partialUpdates);
|
||||
view.visibleSections.clear();
|
||||
view.graph.addSectionsInFrustum(frustum, view.visibleSections);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static void onSectionCompiled(SectionRenderDispatcher.RenderSection section) {
|
||||
for (SectionOcclusionGraph graph : graphs) {
|
||||
graph.onSectionCompiled(section);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkLoaded(ChunkPos pos) {
|
||||
for (SectionOcclusionGraph graph : graphs) {
|
||||
graph.onChunkLoaded(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onChunkDropped(ChunkPos pos) {
|
||||
for (SectionOcclusionGraph graph : graphs) {
|
||||
graph.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
for (View view : VIEWS.values()) {
|
||||
view.release();
|
||||
}
|
||||
VIEWS.clear();
|
||||
publishGraphs();
|
||||
ownerArea = null;
|
||||
mainSectionX = Integer.MIN_VALUE;
|
||||
mainSectionY = Integer.MIN_VALUE;
|
||||
mainSectionZ = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
private static void publishGraphs() {
|
||||
graphs = VIEWS.values().stream().map(view -> view.graph).toArray(SectionOcclusionGraph[]::new);
|
||||
}
|
||||
|
||||
private static void trim() {
|
||||
Iterator<Map.Entry<UUID, View>> iterator = VIEWS.entrySet().iterator();
|
||||
while (VIEWS.size() > MAX_VIEWS && iterator.hasNext()) {
|
||||
View view = iterator.next().getValue();
|
||||
iterator.remove();
|
||||
view.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class View {
|
||||
private final SectionOcclusionGraph graph = new SectionOcclusionGraph();
|
||||
private final List<SectionRenderDispatcher.RenderSection> partialUpdates = new ArrayList<>();
|
||||
private final ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections = new ObjectArrayList<>();
|
||||
private Vec3 seed;
|
||||
private Camera seedCamera;
|
||||
private Frustum updateFrustum;
|
||||
|
||||
private View(ViewArea area) {
|
||||
((PortalSectionGraphMarker) this.graph).antarchy$markPortalGraph();
|
||||
this.graph.waitAndReset(area);
|
||||
}
|
||||
|
||||
public ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections() {
|
||||
return this.visibleSections;
|
||||
}
|
||||
|
||||
private Frustum updateFrustum() {
|
||||
return this.updateFrustum;
|
||||
}
|
||||
|
||||
private void release() {
|
||||
this.graph.waitAndReset(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static Frustum centredFrustum(Vec3 position) {
|
||||
Frustum frustum = new Frustum(new Matrix4f(), new Matrix4f().setPerspective((float) Math.toRadians(90.0D), 1.0F, 0.05F, 1024.0F));
|
||||
frustum.prepare(position.x, position.y, position.z);
|
||||
return frustum;
|
||||
}
|
||||
|
||||
private static final class SeedCamera extends Camera {
|
||||
private SeedCamera(Vec3 position) {
|
||||
this.setPosition(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.MeshData;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexSorting;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public final class PortalGunPortalSkyQueries {
|
||||
private static final int MAX_ENTRIES = 128;
|
||||
private static final LinkedHashMap<Key, QueryState> QUERIES = new LinkedHashMap<>(16, 0.75F, true);
|
||||
|
||||
private PortalGunPortalSkyQueries() {
|
||||
}
|
||||
|
||||
public static boolean shouldRenderSky(UUID source, UUID destination, int level) {
|
||||
QueryState state = QUERIES.get(new Key(source, destination, level));
|
||||
if (state == null) {
|
||||
return true;
|
||||
}
|
||||
poll(state);
|
||||
return !state.hasResult || state.visible;
|
||||
}
|
||||
|
||||
public static void querySkyVisibility(UUID source, UUID destination, int level) {
|
||||
Key key = new Key(source, destination, level);
|
||||
QueryState state = QUERIES.computeIfAbsent(key, ignored -> new QueryState(GL15.glGenQueries()));
|
||||
poll(state);
|
||||
if (state.inFlight) {
|
||||
trim();
|
||||
return;
|
||||
}
|
||||
MeshData mesh = buildFarPlane();
|
||||
if (mesh == null) {
|
||||
trim();
|
||||
return;
|
||||
}
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
int previousDepthFunction = GL11.glGetInteger(GL11.GL_DEPTH_FUNC);
|
||||
modelViewStack.pushMatrix();
|
||||
GL15.glBeginQuery(GL15.GL_SAMPLES_PASSED, state.query);
|
||||
try {
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.colorMask(false, false, false, false);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableCull();
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
modelViewStack.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f(), previousSorting);
|
||||
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||
BufferUploader.drawWithShader(mesh);
|
||||
} finally {
|
||||
GL15.glEndQuery(GL15.GL_SAMPLES_PASSED);
|
||||
state.inFlight = true;
|
||||
GL11.glDepthFunc(previousDepthFunction);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
}
|
||||
trim();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
for (QueryState state : QUERIES.values()) {
|
||||
GL15.glDeleteQueries(state.query);
|
||||
}
|
||||
QUERIES.clear();
|
||||
}
|
||||
|
||||
private static void poll(QueryState state) {
|
||||
if (state.inFlight && GL15.glGetQueryObjecti(state.query, GL15.GL_QUERY_RESULT_AVAILABLE) != 0) {
|
||||
state.visible = GL15.glGetQueryObjecti(state.query, GL15.GL_QUERY_RESULT) != 0;
|
||||
state.hasResult = true;
|
||||
state.inFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static MeshData buildFarPlane() {
|
||||
BufferBuilder buffer = Tesselator.getInstance().begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION);
|
||||
buffer.addVertex(-1.0F, -1.0F, 0.99999F);
|
||||
buffer.addVertex(3.0F, -1.0F, 0.99999F);
|
||||
buffer.addVertex(-1.0F, 3.0F, 0.99999F);
|
||||
return buffer.build();
|
||||
}
|
||||
|
||||
private static void trim() {
|
||||
Iterator<Map.Entry<Key, QueryState>> iterator = QUERIES.entrySet().iterator();
|
||||
while (QUERIES.size() > MAX_ENTRIES && iterator.hasNext()) {
|
||||
QueryState state = iterator.next().getValue();
|
||||
if (!state.inFlight) {
|
||||
GL15.glDeleteQueries(state.query);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record Key(UUID source, UUID destination, int level) {
|
||||
}
|
||||
|
||||
private static final class QueryState {
|
||||
private final int query;
|
||||
private boolean inFlight;
|
||||
private boolean hasResult;
|
||||
private boolean visible = true;
|
||||
|
||||
private QueryState(int query) {
|
||||
this.query = query;
|
||||
}
|
||||
}
|
||||
}
|
||||
-755
@@ -1,755 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.client.PortalGunEntityTransformationStack;
|
||||
import com.craisinlord.antarchy.content.client.PortalGunPortalRenderState;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunPortalEntity;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunProjectionUtil;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunTransformUtil;
|
||||
import com.craisinlord.antarchy.content.portalgun.PortalGunWorldPortalShape;
|
||||
import com.craisinlord.antarchy.mixins.client.CameraBasisAccessor;
|
||||
import com.craisinlord.antarchy.mixins.client.MinecraftMainRenderTargetAccessor;
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.pipeline.TextureTarget;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.MeshData;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexSorting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class PortalGunPortalViewRenderer {
|
||||
private static final int MAX_VIEW_LEVELS = 2;
|
||||
private static final double PORTAL_SEARCH_RADIUS = 128.0D;
|
||||
private static final int PORTAL_TARGET_FILTER = 9729;
|
||||
private static final double SURFACE_OFFSET = 0.04D;
|
||||
private static final double EXIT_CLIP_OFFSET = 0.01D;
|
||||
private static final int APERTURE_SEGMENTS = 32;
|
||||
private static final double APERTURE_RIM_FRACTION = 0.92D;
|
||||
private static TextureTarget offscreenTarget;
|
||||
private static ShaderInstance portalViewShader;
|
||||
private static boolean renderingPortalView;
|
||||
private static boolean loggedMissingPortalViewShader;
|
||||
private static long lastRenderFailureTick = Long.MIN_VALUE;
|
||||
|
||||
private PortalGunPortalViewRenderer() {
|
||||
}
|
||||
|
||||
public static void setPortalViewShader(ShaderInstance shader) {
|
||||
portalViewShader = shader;
|
||||
}
|
||||
|
||||
public static void clearPortalViewShader() {
|
||||
portalViewShader = null;
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return AntarchySettings.portalGunSeeThroughPortals();
|
||||
}
|
||||
|
||||
public static void releaseTargets() {
|
||||
PortalGunPortalVisibilityQueries.clear();
|
||||
PortalGunPortalSkyQueries.clear();
|
||||
PortalGunPortalSectionViews.clear();
|
||||
if (offscreenTarget != null) {
|
||||
offscreenTarget.destroyBuffers();
|
||||
offscreenTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void render(Camera camera, Matrix4f poseMatrix, Matrix4f projectionMatrix, DeltaTracker tickCounter) {
|
||||
if (renderingPortalView) {
|
||||
return;
|
||||
}
|
||||
renderHiddenOutlines(camera, poseMatrix, projectionMatrix, tickCounter);
|
||||
if (isEnabled()) {
|
||||
renderViews(camera, poseMatrix, projectionMatrix, tickCounter);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderHiddenOutlines(Camera camera, Matrix4f poseMatrix, Matrix4f projectionMatrix, DeltaTracker tickCounter) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft.level == null || camera == null || poseMatrix == null || projectionMatrix == null || tickCounter == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
minecraft.getMainRenderTarget().bindWrite(true);
|
||||
PortalGunPortalRim.drawHiddenOutlines(minecraft, camera.getPosition(), new Matrix4f(poseMatrix), new Matrix4f(projectionMatrix),
|
||||
tickCounter.getGameTimeDeltaPartialTick(true));
|
||||
} catch (RuntimeException exception) {
|
||||
logRenderFailure(minecraft, exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderViews(Camera camera, Matrix4f poseMatrix, Matrix4f projectionMatrix, DeltaTracker tickCounter) {
|
||||
PortalRenderWatchdog.frame();
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft.level == null || minecraft.gameRenderer == null || camera == null || poseMatrix == null || projectionMatrix == null || tickCounter == null) {
|
||||
return;
|
||||
}
|
||||
Entity cameraEntity = minecraft.getCameraEntity();
|
||||
if (cameraEntity == null) {
|
||||
return;
|
||||
}
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
Matrix4f rootViewMatrix = new Matrix4f(poseMatrix);
|
||||
Matrix4f rootProjection = new Matrix4f(projectionMatrix);
|
||||
float partialTick = tickCounter.getGameTimeDeltaPartialTick(true);
|
||||
RenderTarget mainTarget = minecraft.getMainRenderTarget();
|
||||
int width = mainTarget.width;
|
||||
int height = mainTarget.height;
|
||||
|
||||
List<PortalGunPortalEntity> portals = collectPortals(minecraft, cameraPos);
|
||||
if (portals.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<RootCandidate> candidates = new ArrayList<>();
|
||||
for (PortalGunPortalEntity portal : portals) {
|
||||
boolean moon = portal.isMoonPortal();
|
||||
PortalGunPortalEntity linked = moon ? null : portal.getLinkedPortal();
|
||||
if (!moon && (linked == null || !linked.isAlive()) || !portal.shouldRenderFront(cameraPos)) {
|
||||
continue;
|
||||
}
|
||||
ScreenClip clip = computeScreenClip(cameraPos, rootViewMatrix, rootProjection, portal, partialTick, width, height);
|
||||
if (clip != null) {
|
||||
candidates.add(new RootCandidate(portal, linked, clip));
|
||||
}
|
||||
}
|
||||
candidates.sort((left, right) -> Integer.compare(right.clip().area(), left.clip().area()));
|
||||
int maxRootViews = AntarchySettings.portalGunMaxLiveViews();
|
||||
if (candidates.size() > maxRootViews) {
|
||||
candidates = candidates.subList(0, maxRootViews);
|
||||
}
|
||||
if (candidates.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean directStencil = PortalStencilTarget.supportsDirect(mainTarget);
|
||||
if (!directStencil && portalViewShader == null) {
|
||||
if (!loggedMissingPortalViewShader) {
|
||||
loggedMissingPortalViewShader = true;
|
||||
Antarchy.LOGGER.error("Portal gun destination view shader is unavailable; skipping offscreen portal rendering");
|
||||
}
|
||||
return;
|
||||
}
|
||||
Matrix4f cameraToWorld = new Matrix4f(rootViewMatrix).invert();
|
||||
Vector3f rootLook = cameraToWorld.transformDirection(new Vector3f(0.0F, 0.0F, -1.0F)).normalize();
|
||||
Vector3f rootUp = cameraToWorld.transformDirection(new Vector3f(0.0F, 1.0F, 0.0F)).normalize();
|
||||
RenderContext rootContext = new RenderContext(cameraPos, new Vec3(rootLook), new Vec3(rootUp), rootViewMatrix);
|
||||
ViewBudget budget = new ViewBudget(maxRootViews * 2);
|
||||
PortalRenderWatchdog.portalViewDrawn();
|
||||
renderingPortalView = true;
|
||||
RenderSystem.backupProjectionMatrix();
|
||||
try {
|
||||
if (directStencil) {
|
||||
PortalStencilTarget.beginFrame(mainTarget);
|
||||
}
|
||||
for (RootCandidate candidate : candidates) {
|
||||
if (!budget.tryReserve()) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
if (candidate.linked() == null) {
|
||||
if (directStencil) {
|
||||
renderMoonViewDirect(minecraft, partialTick, rootContext, rootProjection, candidate.portal(), candidate.clip());
|
||||
} else {
|
||||
renderMoonViewOffscreen(minecraft, partialTick, rootContext, rootProjection, candidate.portal(), candidate.clip());
|
||||
}
|
||||
} else if (directStencil) {
|
||||
renderViewDirect(minecraft, cameraEntity, partialTick, rootContext, rootProjection, rootProjection,
|
||||
candidate.portal(), candidate.linked(), 0, candidate.clip(), null, budget);
|
||||
} else {
|
||||
renderViewOffscreen(minecraft, cameraEntity, partialTick, rootContext, rootProjection,
|
||||
candidate.portal(), candidate.linked(), candidate.clip());
|
||||
}
|
||||
} catch (RuntimeException exception) {
|
||||
logRenderFailure(minecraft, exception);
|
||||
if (directStencil) {
|
||||
PortalStencilTarget.beginFrame(mainTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException exception) {
|
||||
logRenderFailure(minecraft, exception);
|
||||
} finally {
|
||||
try {
|
||||
if (directStencil) {
|
||||
PortalStencilTarget.endFrame();
|
||||
}
|
||||
restorePortalDrawState();
|
||||
mainTarget.bindWrite(true);
|
||||
minecraft.getEntityRenderDispatcher().prepare(minecraft.level, camera, minecraft.crosshairPickEntity);
|
||||
minecraft.getBlockEntityRenderDispatcher().prepare(minecraft.level, camera, minecraft.hitResult);
|
||||
} catch (RuntimeException exception) {
|
||||
logRenderFailure(minecraft, exception);
|
||||
} finally {
|
||||
RenderSystem.restoreProjectionMatrix();
|
||||
renderingPortalView = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderViewDirect(Minecraft minecraft, Entity cameraEntity, float partialTick, RenderContext context,
|
||||
Matrix4f rootProjection, Matrix4f parentProjection,
|
||||
PortalGunPortalEntity source, PortalGunPortalEntity destination,
|
||||
int parentLevel, ScreenClip clip, ScreenClip parentClip, ViewBudget budget) {
|
||||
PortalGunWorldPortalShape exit = destination.getWorldPortalShape();
|
||||
if (!PortalTerrain.canView(minecraft, exit.center())) {
|
||||
return;
|
||||
}
|
||||
boolean root = parentLevel == 0;
|
||||
boolean visible = !root || PortalGunPortalVisibilityQueries.shouldRender(source.getUUID(), destination.getUUID());
|
||||
RenderTarget target = minecraft.getMainRenderTarget();
|
||||
PortalStencilTarget.pushAperture(parentLevel, () -> {
|
||||
boolean queryStarted = root && PortalGunPortalVisibilityQueries.begin(source.getUUID(), destination.getUUID());
|
||||
try {
|
||||
drawPortalMask(context.cameraPos(), context.viewMatrix(), parentProjection, source, partialTick);
|
||||
} finally {
|
||||
if (root) {
|
||||
PortalGunPortalVisibilityQueries.end(source.getUUID(), destination.getUUID(), queryStarted);
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
RenderContext transformed = transformContext(context, source, destination);
|
||||
Matrix4f clippedProjection = applyPortalClipPlane(rootProjection, transformed, destination);
|
||||
RenderSystem.enableScissor(clip.x(), clip.y(), clip.width(), clip.height());
|
||||
renderScene(minecraft, cameraEntity, partialTick, transformed, rootProjection, clippedProjection,
|
||||
source, destination, clip, target.width, target.height, parentLevel + 1);
|
||||
PortalGunPortalRim.drawHiddenOutlines(minecraft, transformed.cameraPos(), transformed.viewMatrix(), clippedProjection,
|
||||
partialTick, destination);
|
||||
if (parentLevel + 1 < MAX_VIEW_LEVELS) {
|
||||
renderNestedViews(minecraft, cameraEntity, partialTick, transformed, rootProjection, clippedProjection,
|
||||
destination, parentLevel + 1, clip, budget, target.width, target.height);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (visible) {
|
||||
PortalStencilTarget.drawInside(parentLevel + 1);
|
||||
PortalGunPortalRim.drawOverView(source, context.cameraPos(), context.viewMatrix(), parentProjection, partialTick);
|
||||
}
|
||||
} finally {
|
||||
PortalStencilTarget.popAperture(parentLevel,
|
||||
() -> restorePortalApertureDepth(context.cameraPos(), context.viewMatrix(), parentProjection, source, partialTick));
|
||||
}
|
||||
if (parentClip == null) {
|
||||
RenderSystem.disableScissor();
|
||||
} else {
|
||||
RenderSystem.enableScissor(parentClip.x(), parentClip.y(), parentClip.width(), parentClip.height());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderMoonViewDirect(Minecraft minecraft, float partialTick, RenderContext context,
|
||||
Matrix4f rootProjection, PortalGunPortalEntity source, ScreenClip clip) {
|
||||
PortalStencilTarget.pushAperture(0, () -> drawPortalMask(context.cameraPos(), context.viewMatrix(), rootProjection, source, partialTick));
|
||||
try {
|
||||
RenderSystem.enableScissor(clip.x(), clip.y(), clip.width(), clip.height());
|
||||
PortalGunMoonViewRenderer.render(minecraft, source.getWorldPortalShape(), context.cameraPos(), context.look(), context.up(),
|
||||
rootProjection, partialTick);
|
||||
} finally {
|
||||
try {
|
||||
PortalStencilTarget.drawInside(1);
|
||||
PortalGunPortalRim.drawOverView(source, context.cameraPos(), context.viewMatrix(), rootProjection, partialTick);
|
||||
} finally {
|
||||
PortalStencilTarget.popAperture(0,
|
||||
() -> restorePortalApertureDepth(context.cameraPos(), context.viewMatrix(), rootProjection, source, partialTick));
|
||||
RenderSystem.disableScissor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderMoonViewOffscreen(Minecraft minecraft, float partialTick, RenderContext context,
|
||||
Matrix4f rootProjection, PortalGunPortalEntity source, ScreenClip clip) {
|
||||
RenderTarget mainTarget = minecraft.getMainRenderTarget();
|
||||
TextureTarget target = ensureOffscreenTarget(mainTarget.width, mainTarget.height);
|
||||
MinecraftMainRenderTargetAccessor targetAccessor = (MinecraftMainRenderTargetAccessor) minecraft;
|
||||
targetAccessor.antarchy$setMainRenderTarget(target);
|
||||
try {
|
||||
target.bindWrite(true);
|
||||
RenderSystem.disableScissor();
|
||||
target.clear(Minecraft.ON_OSX);
|
||||
target.bindWrite(true);
|
||||
RenderSystem.enableScissor(clip.x(), clip.y(), clip.width(), clip.height());
|
||||
PortalGunMoonViewRenderer.render(minecraft, source.getWorldPortalShape(), context.cameraPos(), context.look(), context.up(),
|
||||
rootProjection, partialTick);
|
||||
} finally {
|
||||
RenderSystem.disableScissor();
|
||||
targetAccessor.antarchy$setMainRenderTarget(mainTarget);
|
||||
mainTarget.bindWrite(true);
|
||||
}
|
||||
RenderSystem.setProjectionMatrix(rootProjection, VertexSorting.DISTANCE_TO_ORIGIN);
|
||||
drawPortalComposite(context.cameraPos(), context.viewMatrix(), rootProjection, source, partialTick, target.getColorTextureId());
|
||||
}
|
||||
|
||||
private static void renderNestedViews(Minecraft minecraft, Entity cameraEntity, float partialTick, RenderContext viewContext,
|
||||
Matrix4f rootProjection, Matrix4f viewProjection, PortalGunPortalEntity exit,
|
||||
int level, ScreenClip viewClip, ViewBudget budget, int width, int height) {
|
||||
PortalGunWorldPortalShape exitShape = exit.getWorldPortalShape();
|
||||
for (PortalGunPortalEntity child : collectPortals(minecraft, viewContext.cameraPos())) {
|
||||
if (!budget.hasRemaining()) {
|
||||
return;
|
||||
}
|
||||
PortalGunPortalEntity childLinked = child.getLinkedPortal();
|
||||
if (child == exit || childLinked == null || !childLinked.isAlive()
|
||||
|| !child.shouldRenderFront(viewContext.cameraPos())
|
||||
|| !exitShape.intersectsFront(child.getBoundingBox(), 0.0D)) {
|
||||
continue;
|
||||
}
|
||||
ScreenClip childClip = computeScreenClip(viewContext.cameraPos(), viewContext.viewMatrix(), viewProjection,
|
||||
child, partialTick, width, height);
|
||||
childClip = childClip == null ? null : childClip.intersect(viewClip);
|
||||
if (childClip == null || !budget.tryReserve()) {
|
||||
continue;
|
||||
}
|
||||
renderViewDirect(minecraft, cameraEntity, partialTick, viewContext, rootProjection, viewProjection,
|
||||
child, childLinked, level, childClip, viewClip, budget);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderViewOffscreen(Minecraft minecraft, Entity cameraEntity, float partialTick, RenderContext context,
|
||||
Matrix4f rootProjection, PortalGunPortalEntity source,
|
||||
PortalGunPortalEntity destination, ScreenClip clip) {
|
||||
if (!PortalTerrain.canView(minecraft, destination.getWorldPortalShape().center())) {
|
||||
return;
|
||||
}
|
||||
RenderTarget mainTarget = minecraft.getMainRenderTarget();
|
||||
TextureTarget target = ensureOffscreenTarget(mainTarget.width, mainTarget.height);
|
||||
RenderContext transformed = transformContext(context, source, destination);
|
||||
Matrix4f clippedProjection = applyPortalClipPlane(rootProjection, transformed, destination);
|
||||
MinecraftMainRenderTargetAccessor targetAccessor = (MinecraftMainRenderTargetAccessor) minecraft;
|
||||
targetAccessor.antarchy$setMainRenderTarget(target);
|
||||
try {
|
||||
target.bindWrite(true);
|
||||
RenderSystem.disableScissor();
|
||||
target.clear(Minecraft.ON_OSX);
|
||||
target.bindWrite(true);
|
||||
RenderSystem.enableScissor(clip.x(), clip.y(), clip.width(), clip.height());
|
||||
renderScene(minecraft, cameraEntity, partialTick, transformed, rootProjection, clippedProjection,
|
||||
source, destination, clip, target.width, target.height, 1);
|
||||
PortalGunPortalRim.drawHiddenOutlines(minecraft, transformed.cameraPos(), transformed.viewMatrix(), clippedProjection,
|
||||
partialTick, destination);
|
||||
} finally {
|
||||
RenderSystem.disableScissor();
|
||||
targetAccessor.antarchy$setMainRenderTarget(mainTarget);
|
||||
mainTarget.bindWrite(true);
|
||||
}
|
||||
RenderSystem.setProjectionMatrix(rootProjection, VertexSorting.DISTANCE_TO_ORIGIN);
|
||||
drawPortalComposite(context.cameraPos(), context.viewMatrix(), rootProjection, source, partialTick, target.getColorTextureId());
|
||||
}
|
||||
|
||||
private static void renderScene(Minecraft minecraft, Entity cameraEntity, float partialTick, RenderContext transformed,
|
||||
Matrix4f rootProjection, Matrix4f clippedProjection,
|
||||
PortalGunPortalEntity source, PortalGunPortalEntity destination,
|
||||
ScreenClip clip, int width, int height, int level) {
|
||||
PortalGunWorldPortalShape exit = destination.getWorldPortalShape();
|
||||
PortalCamera portalCamera = new PortalCamera();
|
||||
portalCamera.setup(minecraft.level, cameraEntity, partialTick, transformed.cameraPos(), transformed.look(), transformed.up());
|
||||
Frustum frustum = new Frustum(transformed.viewMatrix(), cropProjectionToScreenClip(rootProjection, clip, width, height));
|
||||
frustum.prepare(transformed.cameraPos().x, transformed.cameraPos().y, transformed.cameraPos().z);
|
||||
PortalGunPortalRenderState.pushPortalView(new PortalGunPortalRenderState.PortalRenderContext(
|
||||
source.getWorldPortalShape(), exit, transformed.cameraPos(), transformed.look(), transformed.up(),
|
||||
transformed.viewMatrix(), clippedProjection, level, false, destination.getUUID()));
|
||||
try {
|
||||
PortalTerrain terrain = PortalTerrain.prepare(minecraft, destination.getUUID(), exit.center(), exit.normal(), frustum);
|
||||
PortalGunPortalSceneRenderer.render(minecraft, portalCamera, partialTick, transformed.viewMatrix(), clippedProjection,
|
||||
rootProjection, frustum, terrain,
|
||||
poseStack -> renderCrossingEntities(minecraft, transformed.cameraPos(), partialTick, source, destination, poseStack),
|
||||
source.getUUID(), destination.getUUID(), level);
|
||||
} finally {
|
||||
PortalGunPortalRenderState.popPortalView(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<PortalGunPortalEntity> collectPortals(Minecraft minecraft, Vec3 cameraPos) {
|
||||
List<PortalGunPortalEntity> portals = new ArrayList<>();
|
||||
for (PortalGunPortalEntity portal : com.craisinlord.antarchy.content.portalgun.PortalGunPortalRegistry.all(minecraft.level)) {
|
||||
if (portal.isAlive() && portal.distanceToSqr(cameraPos) <= PORTAL_SEARCH_RADIUS * PORTAL_SEARCH_RADIUS) {
|
||||
portals.add(portal);
|
||||
}
|
||||
}
|
||||
portals.sort((left, right) -> Double.compare(left.distanceToSqr(cameraPos), right.distanceToSqr(cameraPos)));
|
||||
return portals;
|
||||
}
|
||||
|
||||
private static void logRenderFailure(Minecraft minecraft, RuntimeException exception) {
|
||||
long gameTime = minecraft.level == null ? Long.MIN_VALUE : minecraft.level.getGameTime();
|
||||
if (lastRenderFailureTick == Long.MIN_VALUE || gameTime == Long.MIN_VALUE || gameTime - lastRenderFailureTick >= 100L) {
|
||||
lastRenderFailureTick = gameTime;
|
||||
Antarchy.LOGGER.error("Portal gun portal view render failed", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static TextureTarget ensureOffscreenTarget(int width, int height) {
|
||||
if (offscreenTarget == null) {
|
||||
offscreenTarget = new TextureTarget(width, height, true, Minecraft.ON_OSX);
|
||||
offscreenTarget.setClearColor(0.0F, 0.0F, 0.0F, 1.0F);
|
||||
} else if (offscreenTarget.width != width || offscreenTarget.height != height) {
|
||||
offscreenTarget.resize(width, height, Minecraft.ON_OSX);
|
||||
}
|
||||
offscreenTarget.setFilterMode(PORTAL_TARGET_FILTER);
|
||||
return offscreenTarget;
|
||||
}
|
||||
|
||||
private static RenderContext transformContext(RenderContext context, PortalGunPortalEntity source, PortalGunPortalEntity destination) {
|
||||
PortalGunWorldPortalShape sourceShape = source.getWorldPortalShape();
|
||||
PortalGunWorldPortalShape destinationShape = destination.getWorldPortalShape();
|
||||
Vec3 relativeEye = context.cameraPos().subtract(sourceShape.center());
|
||||
Vec3 destinationEye = destinationShape.center().add(PortalGunTransformUtil.transformPosition(sourceShape, destinationShape, relativeEye));
|
||||
Vec3 look = PortalGunTransformUtil.transformVector(sourceShape, destinationShape, context.look()).normalize();
|
||||
Vec3 up = PortalGunTransformUtil.transformVector(sourceShape, destinationShape, context.up()).normalize();
|
||||
Matrix4f viewMatrix = new Matrix4f().rotation(PortalGunTransformUtil.orientationQuaternion(look, up).conjugate(new Quaternionf()));
|
||||
return new RenderContext(destinationEye, look, up, viewMatrix);
|
||||
}
|
||||
|
||||
private static Matrix4f applyPortalClipPlane(Matrix4f projection, RenderContext context, PortalGunPortalEntity destination) {
|
||||
PortalGunWorldPortalShape exit = destination.getWorldPortalShape();
|
||||
return PortalGunProjectionUtil.clipAtExit(projection, context.cameraPos(), context.look(), context.up(),
|
||||
exit.center().add(exit.normal().scale(EXIT_CLIP_OFFSET)), exit.normal());
|
||||
}
|
||||
|
||||
private static ScreenClip computeScreenClip(Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix,
|
||||
PortalGunPortalEntity portal, float partialTick, int width, int height) {
|
||||
List<Vector4f> clipVertices = projectPortalPolygon(new Matrix4f(projectionMatrix).mul(viewMatrix), cameraPos, portal, partialTick);
|
||||
if (clipVertices.size() < 3) {
|
||||
return null;
|
||||
}
|
||||
float minX = Float.POSITIVE_INFINITY;
|
||||
float minY = Float.POSITIVE_INFINITY;
|
||||
float maxX = Float.NEGATIVE_INFINITY;
|
||||
float maxY = Float.NEGATIVE_INFINITY;
|
||||
for (Vector4f projected : clipVertices) {
|
||||
float invW = 1.0F / projected.w;
|
||||
float screenX = (projected.x * invW * 0.5F + 0.5F) * width;
|
||||
float screenY = (projected.y * invW * 0.5F + 0.5F) * height;
|
||||
minX = Math.min(minX, screenX);
|
||||
minY = Math.min(minY, screenY);
|
||||
maxX = Math.max(maxX, screenX);
|
||||
maxY = Math.max(maxY, screenY);
|
||||
}
|
||||
if (maxX <= 0.0F || minX >= width || maxY <= 0.0F || minY >= height) {
|
||||
return null;
|
||||
}
|
||||
int x = Mth.clamp((int) Math.floor(minX), 0, width - 1);
|
||||
int maxClipX = Mth.clamp((int) Math.ceil(maxX), x + 1, width);
|
||||
int y = Mth.clamp((int) Math.floor(minY), 0, height - 1);
|
||||
int maxClipY = Mth.clamp((int) Math.ceil(maxY), y + 1, height);
|
||||
return new ScreenClip(x, y, maxClipX - x, maxClipY - y);
|
||||
}
|
||||
|
||||
private static Matrix4f cropProjectionToScreenClip(Matrix4f projectionMatrix, ScreenClip clip, int width, int height) {
|
||||
float left = (float) (clip.x() * 2.0D / width - 1.0D);
|
||||
float right = (float) ((clip.x() + clip.width()) * 2.0D / width - 1.0D);
|
||||
float bottom = (float) (clip.y() * 2.0D / height - 1.0D);
|
||||
float top = (float) ((clip.y() + clip.height()) * 2.0D / height - 1.0D);
|
||||
float widthNdc = Math.max(1.0E-5F, right - left);
|
||||
float heightNdc = Math.max(1.0E-5F, top - bottom);
|
||||
return new Matrix4f()
|
||||
.translate(-(right + left) / widthNdc, -(top + bottom) / heightNdc, 0.0F)
|
||||
.scale(2.0F / widthNdc, 2.0F / heightNdc, 1.0F)
|
||||
.mul(projectionMatrix);
|
||||
}
|
||||
|
||||
private static List<Vector4f> clipPolygon(List<Vector4f> vertices, boolean nearPlane) {
|
||||
if (vertices.isEmpty()) {
|
||||
return vertices;
|
||||
}
|
||||
List<Vector4f> clipped = new ArrayList<>(vertices.size() + 2);
|
||||
Vector4f previous = vertices.get(vertices.size() - 1);
|
||||
float previousDistance = clipPlaneDistance(previous, nearPlane);
|
||||
for (Vector4f current : vertices) {
|
||||
float currentDistance = clipPlaneDistance(current, nearPlane);
|
||||
boolean previousInside = previousDistance >= 0.0F;
|
||||
boolean currentInside = currentDistance >= 0.0F;
|
||||
if (previousInside != currentInside) {
|
||||
float amount = previousDistance / (previousDistance - currentDistance);
|
||||
clipped.add(new Vector4f(
|
||||
previous.x + (current.x - previous.x) * amount,
|
||||
previous.y + (current.y - previous.y) * amount,
|
||||
previous.z + (current.z - previous.z) * amount,
|
||||
previous.w + (current.w - previous.w) * amount
|
||||
));
|
||||
}
|
||||
if (currentInside) {
|
||||
clipped.add(new Vector4f(current));
|
||||
}
|
||||
previous = current;
|
||||
previousDistance = currentDistance;
|
||||
}
|
||||
return clipped;
|
||||
}
|
||||
|
||||
private static float clipPlaneDistance(Vector4f vertex, boolean nearPlane) {
|
||||
return nearPlane ? vertex.z + vertex.w : vertex.w - 0.001F;
|
||||
}
|
||||
|
||||
private static List<Vector4f> projectPortalPolygon(Matrix4f combined, Vec3 cameraPos, PortalGunPortalEntity portal, float partialTick) {
|
||||
Vec3[] corners = apertureOutline(portal, partialTick);
|
||||
List<Vector4f> polygon = new ArrayList<>(corners.length);
|
||||
for (Vec3 corner : corners) {
|
||||
Vec3 relative = corner.subtract(cameraPos);
|
||||
polygon.add(new Vector4f((float) relative.x, (float) relative.y, (float) relative.z, 1.0F).mul(combined));
|
||||
}
|
||||
polygon = clipPolygon(polygon, false);
|
||||
return clipPolygon(polygon, true);
|
||||
}
|
||||
|
||||
static Vec3[] apertureOutline(PortalGunPortalEntity portal, float partialTick) {
|
||||
float scale = portal.getPortalVisualScale(partialTick);
|
||||
PortalGunWorldPortalShape shape = portal.getWorldPortalShape().scaleAperture(scale);
|
||||
double radiusHorizontal = Math.min(shape.halfWidth(), (shape.halfWidth() + PortalGunPortalRim.EXTRA_WIDTH * scale) * APERTURE_RIM_FRACTION);
|
||||
double radiusVertical = Math.min(shape.halfHeight(), (shape.halfHeight() + PortalGunPortalRim.EXTRA_HEIGHT * scale) * APERTURE_RIM_FRACTION);
|
||||
return shape.getOutline(SURFACE_OFFSET, APERTURE_SEGMENTS, radiusHorizontal, radiusVertical);
|
||||
}
|
||||
|
||||
private static MeshData buildAperture(Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix,
|
||||
PortalGunPortalEntity portal, float partialTick, boolean withScreenUv) {
|
||||
List<Vector4f> polygon = projectPortalPolygon(new Matrix4f(projectionMatrix).mul(viewMatrix), cameraPos, portal, partialTick);
|
||||
if (polygon.size() < 3) {
|
||||
return null;
|
||||
}
|
||||
BufferBuilder buffer = Tesselator.getInstance().begin(VertexFormat.Mode.TRIANGLES,
|
||||
withScreenUv ? DefaultVertexFormat.POSITION_TEX : DefaultVertexFormat.POSITION);
|
||||
for (int index = 1; index + 1 < polygon.size(); index++) {
|
||||
addClipVertex(buffer, polygon.get(0), withScreenUv);
|
||||
addClipVertex(buffer, polygon.get(index), withScreenUv);
|
||||
addClipVertex(buffer, polygon.get(index + 1), withScreenUv);
|
||||
}
|
||||
return buffer.build();
|
||||
}
|
||||
|
||||
private static void addClipVertex(BufferBuilder buffer, Vector4f clipPosition, boolean withScreenUv) {
|
||||
float inverseW = 1.0F / clipPosition.w();
|
||||
float ndcX = clipPosition.x() * inverseW;
|
||||
float ndcY = clipPosition.y() * inverseW;
|
||||
float ndcZ = clipPosition.z() * inverseW;
|
||||
if (withScreenUv) {
|
||||
buffer.addVertex(ndcX, ndcY, ndcZ).setUv(ndcX * 0.5F + 0.5F, ndcY * 0.5F + 0.5F);
|
||||
} else {
|
||||
buffer.addVertex(ndcX, ndcY, ndcZ);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawPortalMask(Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix, PortalGunPortalEntity portal, float partialTick) {
|
||||
drawClipSpaceMesh(buildAperture(cameraPos, viewMatrix, projectionMatrix, portal, partialTick, false));
|
||||
}
|
||||
|
||||
private static void restorePortalApertureDepth(Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix,
|
||||
PortalGunPortalEntity portal, float partialTick) {
|
||||
MeshData mesh = buildAperture(cameraPos, viewMatrix, projectionMatrix, portal, partialTick, false);
|
||||
int previousDepthFunction = GL11.glGetInteger(GL11.GL_DEPTH_FUNC);
|
||||
GL11.glDepthFunc(GL11.GL_ALWAYS);
|
||||
try {
|
||||
drawClipSpaceMesh(mesh);
|
||||
} finally {
|
||||
GL11.glDepthFunc(previousDepthFunction);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawClipSpaceMesh(MeshData mesh) {
|
||||
if (mesh == null) {
|
||||
return;
|
||||
}
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
modelViewStack.pushMatrix();
|
||||
try {
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableBlend();
|
||||
modelViewStack.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f(), previousSorting);
|
||||
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
BufferUploader.drawWithShader(mesh);
|
||||
} finally {
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.enableCull();
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawPortalComposite(Vec3 cameraPos, Matrix4f viewMatrix, Matrix4f projectionMatrix,
|
||||
PortalGunPortalEntity portal, float partialTick, int textureId) {
|
||||
MeshData mesh = buildAperture(cameraPos, viewMatrix, projectionMatrix, portal, partialTick, true);
|
||||
if (mesh == null || portalViewShader == null) {
|
||||
if (mesh != null) {
|
||||
mesh.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Matrix4fStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
Matrix4f previousProjection = new Matrix4f(RenderSystem.getProjectionMatrix());
|
||||
VertexSorting previousSorting = RenderSystem.getVertexSorting();
|
||||
modelViewStack.pushMatrix();
|
||||
try {
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableCull();
|
||||
modelViewStack.identity();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
RenderSystem.setProjectionMatrix(new Matrix4f(), previousSorting);
|
||||
portalViewShader.setSampler("Sampler0", textureId);
|
||||
RenderSystem.setShader(() -> portalViewShader);
|
||||
RenderSystem.setShaderTexture(0, textureId);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
BufferUploader.drawWithShader(mesh);
|
||||
} finally {
|
||||
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
|
||||
modelViewStack.popMatrix();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
restorePortalDrawState();
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderCrossingEntities(Minecraft minecraft, Vec3 cameraPos, float partialTick,
|
||||
PortalGunPortalEntity sourcePortal, PortalGunPortalEntity destinationPortal, PoseStack poseStack) {
|
||||
MultiBufferSource.BufferSource bufferSource = PortalGunPortalSceneRenderer.bufferSource();
|
||||
List<Entity> entities = minecraft.level.getEntities((Entity) null, sourcePortal.getWorldPortalShape().getBoundsForCulling(),
|
||||
entity -> isCrossing(entity, sourcePortal, destinationPortal));
|
||||
Set<Entity> rendered = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
try {
|
||||
for (Entity entity : entities) {
|
||||
renderCrossingEntityTree(minecraft, cameraPos, partialTick, sourcePortal, destinationPortal, entity, poseStack, bufferSource, rendered);
|
||||
}
|
||||
} finally {
|
||||
bufferSource.endBatch();
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderCrossingEntityTree(Minecraft minecraft, Vec3 cameraPos, float partialTick, PortalGunPortalEntity sourcePortal,
|
||||
PortalGunPortalEntity destinationPortal, Entity entity, PoseStack poseStack,
|
||||
MultiBufferSource.BufferSource bufferSource, Set<Entity> rendered) {
|
||||
if (!isCrossing(entity, sourcePortal, destinationPortal) || !rendered.add(entity)) {
|
||||
return;
|
||||
}
|
||||
PortalGunEntityTransformationStack transformationStack = new PortalGunEntityTransformationStack(entity);
|
||||
transformationStack.push();
|
||||
try {
|
||||
Vec3 position = transformationStack.moveEntity(sourcePortal, destinationPortal, partialTick);
|
||||
float yaw = Mth.rotLerp(partialTick, entity.yRotO, entity.getYRot());
|
||||
int light = minecraft.getEntityRenderDispatcher().getPackedLightCoords(entity, partialTick);
|
||||
PortalGunPortalRenderState.pushDestinationShape(destinationPortal.getWorldPortalShape());
|
||||
try {
|
||||
minecraft.getEntityRenderDispatcher().render(entity, position.x - cameraPos.x, position.y - cameraPos.y,
|
||||
position.z - cameraPos.z, yaw, partialTick, poseStack, bufferSource, light);
|
||||
} finally {
|
||||
PortalGunPortalRenderState.popDestinationShape();
|
||||
}
|
||||
} finally {
|
||||
transformationStack.pop();
|
||||
}
|
||||
for (Entity passenger : entity.getPassengers()) {
|
||||
renderCrossingEntityTree(minecraft, cameraPos, partialTick, sourcePortal, destinationPortal, passenger, poseStack, bufferSource, rendered);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCrossing(Entity entity, PortalGunPortalEntity sourcePortal, PortalGunPortalEntity destinationPortal) {
|
||||
return entity != null
|
||||
&& entity.isAlive()
|
||||
&& !(entity instanceof PortalGunPortalEntity)
|
||||
&& entity != sourcePortal
|
||||
&& entity != destinationPortal
|
||||
&& entity != Minecraft.getInstance().getCameraEntity()
|
||||
&& sourcePortal.intersectsEntityBounds(entity);
|
||||
}
|
||||
|
||||
private static void restorePortalDrawState() {
|
||||
RenderSystem.disableScissor();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private static final class PortalCamera extends Camera {
|
||||
private void setup(net.minecraft.world.level.BlockGetter level, Entity cameraEntity, float partialTick, Vec3 position, Vec3 look, Vec3 up) {
|
||||
super.setup(level, cameraEntity, true, false, partialTick);
|
||||
Vec3 normalizedLook = look.normalize();
|
||||
Vec3 normalizedUp = up.subtract(normalizedLook.scale(up.dot(normalizedLook))).normalize();
|
||||
this.setPosition(position);
|
||||
this.setRotation(PortalGunTransformUtil.yawFromLook(normalizedLook), PortalGunTransformUtil.pitchFromLook(normalizedLook));
|
||||
Quaternionf orientation = PortalGunTransformUtil.orientationQuaternion(normalizedLook, normalizedUp);
|
||||
this.rotation().set(orientation);
|
||||
CameraBasisAccessor basis = (CameraBasisAccessor) (Object) this;
|
||||
basis.antarchy$getForwards().set(0.0F, 0.0F, -1.0F).rotate(orientation);
|
||||
basis.antarchy$getUp().set(0.0F, 1.0F, 0.0F).rotate(orientation);
|
||||
basis.antarchy$getLeft().set(-1.0F, 0.0F, 0.0F).rotate(orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private record RenderContext(Vec3 cameraPos, Vec3 look, Vec3 up, Matrix4f viewMatrix) {
|
||||
}
|
||||
|
||||
private record RootCandidate(PortalGunPortalEntity portal, PortalGunPortalEntity linked, ScreenClip clip) {
|
||||
}
|
||||
|
||||
private static final class ViewBudget {
|
||||
private int remaining;
|
||||
|
||||
private ViewBudget(int maximumViews) {
|
||||
this.remaining = maximumViews;
|
||||
}
|
||||
|
||||
private boolean tryReserve() {
|
||||
if (this.remaining <= 0) {
|
||||
return false;
|
||||
}
|
||||
this.remaining--;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasRemaining() {
|
||||
return this.remaining > 0;
|
||||
}
|
||||
}
|
||||
|
||||
private record ScreenClip(int x, int y, int width, int height) {
|
||||
private int area() {
|
||||
return this.width * this.height;
|
||||
}
|
||||
|
||||
private ScreenClip intersect(ScreenClip other) {
|
||||
int minX = Math.max(this.x, other.x);
|
||||
int minY = Math.max(this.y, other.y);
|
||||
int maxX = Math.min(this.x + this.width, other.x + other.width);
|
||||
int maxY = Math.min(this.y + this.height, other.y + other.height);
|
||||
return maxX <= minX || maxY <= minY ? null : new ScreenClip(minX, minY, maxX - minX, maxY - minY);
|
||||
}
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public final class PortalGunPortalVisibilityQueries {
|
||||
private static final int MAX_ENTRIES = 128;
|
||||
private static final LinkedHashMap<Pair, QueryState> QUERIES = new LinkedHashMap<>(16, 0.75F, true);
|
||||
|
||||
private PortalGunPortalVisibilityQueries() {
|
||||
}
|
||||
|
||||
public static boolean shouldRender(UUID source, UUID destination) {
|
||||
QueryState state = QUERIES.get(new Pair(source, destination));
|
||||
if (state == null) {
|
||||
return true;
|
||||
}
|
||||
if (state.inFlight && GL15.glGetQueryObjecti(state.query, GL15.GL_QUERY_RESULT_AVAILABLE) != 0) {
|
||||
state.visible = GL15.glGetQueryObjecti(state.query, GL15.GL_QUERY_RESULT) != 0;
|
||||
state.hasResult = true;
|
||||
state.inFlight = false;
|
||||
}
|
||||
return !state.hasResult || state.visible;
|
||||
}
|
||||
|
||||
public static boolean begin(UUID source, UUID destination) {
|
||||
Pair pair = new Pair(source, destination);
|
||||
QueryState state = QUERIES.computeIfAbsent(pair, key -> new QueryState(GL15.glGenQueries()));
|
||||
if (state.inFlight || state.active) {
|
||||
trim();
|
||||
return false;
|
||||
}
|
||||
state.active = true;
|
||||
try {
|
||||
GL15.glBeginQuery(GL15.GL_SAMPLES_PASSED, state.query);
|
||||
} catch (RuntimeException | Error exception) {
|
||||
state.active = false;
|
||||
throw exception;
|
||||
}
|
||||
trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void end(UUID source, UUID destination, boolean started) {
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
QueryState state = QUERIES.get(new Pair(source, destination));
|
||||
if (state == null || !state.active) {
|
||||
return;
|
||||
}
|
||||
GL15.glEndQuery(GL15.GL_SAMPLES_PASSED);
|
||||
state.active = false;
|
||||
state.inFlight = true;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
for (QueryState state : QUERIES.values()) {
|
||||
GL15.glDeleteQueries(state.query);
|
||||
}
|
||||
QUERIES.clear();
|
||||
}
|
||||
|
||||
private static void trim() {
|
||||
Iterator<Map.Entry<Pair, QueryState>> iterator = QUERIES.entrySet().iterator();
|
||||
while (QUERIES.size() > MAX_ENTRIES && iterator.hasNext()) {
|
||||
QueryState state = iterator.next().getValue();
|
||||
if (!state.active) {
|
||||
GL15.glDeleteQueries(state.query);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record Pair(UUID source, UUID destination) {
|
||||
}
|
||||
|
||||
private static final class QueryState {
|
||||
private final int query;
|
||||
private boolean active;
|
||||
private boolean inFlight;
|
||||
private boolean hasResult;
|
||||
private boolean visible = true;
|
||||
|
||||
private QueryState(int query) {
|
||||
this.query = query;
|
||||
}
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
|
||||
final class PortalRenderWatchdog {
|
||||
private static final long STALL_NANOS = 5_000_000_000L;
|
||||
private static final long RECENT_PORTAL_NANOS = 10_000_000_000L;
|
||||
private static volatile Thread renderThread;
|
||||
private static volatile long lastFrameNanos;
|
||||
private static volatile long lastPortalViewNanos = Long.MIN_VALUE;
|
||||
private static volatile boolean reportedStall;
|
||||
private static Thread watcher;
|
||||
|
||||
private PortalRenderWatchdog() {
|
||||
}
|
||||
|
||||
static void frame() {
|
||||
lastFrameNanos = System.nanoTime();
|
||||
reportedStall = false;
|
||||
if (watcher == null) {
|
||||
renderThread = Thread.currentThread();
|
||||
watcher = new Thread(PortalRenderWatchdog::watch, "Antarchy portal render watchdog");
|
||||
watcher.setDaemon(true);
|
||||
watcher.start();
|
||||
}
|
||||
}
|
||||
|
||||
static void portalViewDrawn() {
|
||||
lastPortalViewNanos = System.nanoTime();
|
||||
}
|
||||
|
||||
private static void watch() {
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException exception) {
|
||||
return;
|
||||
}
|
||||
long now = System.nanoTime();
|
||||
long lastFrame = lastFrameNanos;
|
||||
long lastPortal = lastPortalViewNanos;
|
||||
Thread thread = renderThread;
|
||||
if (reportedStall || thread == null || lastPortal == Long.MIN_VALUE
|
||||
|| now - lastFrame < STALL_NANOS || lastFrame - lastPortal > RECENT_PORTAL_NANOS) {
|
||||
continue;
|
||||
}
|
||||
reportedStall = true;
|
||||
StringBuilder stack = new StringBuilder();
|
||||
for (StackTraceElement element : thread.getStackTrace()) {
|
||||
stack.append("\n\tat ").append(element);
|
||||
}
|
||||
Antarchy.LOGGER.warn("Render thread has not finished a frame for {} ms after portal views were drawn (state {}). Stack:{}",
|
||||
(now - lastFrame) / 1_000_000L, thread.getState(), stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
public interface PortalSectionGraphMarker {
|
||||
void antarchy$markPortalGraph();
|
||||
}
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public final class PortalStencilTarget {
|
||||
private static final int GL_INCR = 7682;
|
||||
private static final int GL_DECR = 7683;
|
||||
private static final Map<RenderTarget, Attachment> MAIN_STENCIL_ATTACHMENTS = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
private static final Map<RenderTarget, Integer> UNSUPPORTED_MAIN_TARGETS = Collections.synchronizedMap(new IdentityHashMap<>());
|
||||
|
||||
private PortalStencilTarget() {
|
||||
}
|
||||
|
||||
public static void prepareMainTarget(RenderTarget target) {
|
||||
target.bindWrite(true);
|
||||
if (stencilBits() > 0) {
|
||||
UNSUPPORTED_MAIN_TARGETS.remove(target);
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(UNSUPPORTED_MAIN_TARGETS.get(target), target.frameBufferId)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
java.lang.reflect.Method enabled = target.getClass().getMethod("isStencilEnabled");
|
||||
if (!Boolean.TRUE.equals(enabled.invoke(target))) {
|
||||
target.getClass().getMethod("enableStencil").invoke(target);
|
||||
}
|
||||
} catch (ReflectiveOperationException ignored) {
|
||||
}
|
||||
target.bindWrite(true);
|
||||
if (stencilBits() <= 0) {
|
||||
try {
|
||||
ensureMainStencilAttachment(target);
|
||||
} catch (IllegalStateException exception) {
|
||||
UNSUPPORTED_MAIN_TARGETS.put(target, target.frameBufferId);
|
||||
Antarchy.LOGGER.debug("Portal gun direct stencil is unavailable ({}); using offscreen portal rendering", exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean supportsDirect(RenderTarget target) {
|
||||
target.bindWrite(true);
|
||||
return stencilBits() > 0;
|
||||
}
|
||||
|
||||
public static void beginFrame(RenderTarget target) {
|
||||
target.bindWrite(true);
|
||||
RenderSystem.disableScissor();
|
||||
RenderSystem.stencilMask(0xFF);
|
||||
RenderSystem.clearStencil(0);
|
||||
GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
drawInside(0);
|
||||
}
|
||||
|
||||
public static void endFrame() {
|
||||
GL11.glDisable(GL11.GL_STENCIL_TEST);
|
||||
RenderSystem.stencilMask(0xFF);
|
||||
RenderSystem.stencilFunc(GL11.GL_ALWAYS, 0, 0xFF);
|
||||
RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
|
||||
public static void pushAperture(int parentLevel, Runnable drawAperture) {
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
RenderSystem.stencilMask(0xFF);
|
||||
RenderSystem.stencilFunc(GL11.GL_EQUAL, parentLevel, 0xFF);
|
||||
RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL_INCR);
|
||||
RenderSystem.colorMask(false, false, false, false);
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableDepthTest();
|
||||
try {
|
||||
drawAperture.run();
|
||||
} finally {
|
||||
drawInside(parentLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void popAperture(int parentLevel, Runnable drawApertureDepth) {
|
||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
||||
RenderSystem.stencilMask(0xFF);
|
||||
RenderSystem.stencilFunc(GL11.GL_EQUAL, parentLevel + 1, 0xFF);
|
||||
RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL_DECR);
|
||||
RenderSystem.colorMask(false, false, false, false);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
try {
|
||||
drawApertureDepth.run();
|
||||
} finally {
|
||||
drawInside(parentLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawInside(int level) {
|
||||
RenderSystem.stencilMask(0x00);
|
||||
RenderSystem.stencilFunc(GL11.GL_EQUAL, level, 0xFF);
|
||||
RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
|
||||
public static void release(RenderTarget target) {
|
||||
UNSUPPORTED_MAIN_TARGETS.remove(target);
|
||||
Attachment mainAttachment = MAIN_STENCIL_ATTACHMENTS.remove(target);
|
||||
if (mainAttachment != null) {
|
||||
GL30.glDeleteRenderbuffers(mainAttachment.renderbuffer());
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
for (Attachment attachment : MAIN_STENCIL_ATTACHMENTS.values()) {
|
||||
GL30.glDeleteRenderbuffers(attachment.renderbuffer());
|
||||
}
|
||||
MAIN_STENCIL_ATTACHMENTS.clear();
|
||||
UNSUPPORTED_MAIN_TARGETS.clear();
|
||||
}
|
||||
|
||||
private static void ensureMainStencilAttachment(RenderTarget target) {
|
||||
Attachment attachment = MAIN_STENCIL_ATTACHMENTS.get(target);
|
||||
if (attachment != null
|
||||
&& attachment.framebuffer() == target.frameBufferId
|
||||
&& attachment.width() == target.width
|
||||
&& attachment.height() == target.height) {
|
||||
throw new IllegalStateException("Main render target stencil attachment has no stencil bits");
|
||||
}
|
||||
if (attachment != null) {
|
||||
GL30.glDeleteRenderbuffers(attachment.renderbuffer());
|
||||
MAIN_STENCIL_ATTACHMENTS.remove(target);
|
||||
}
|
||||
int previousRenderbuffer = GL11.glGetInteger(GL30.GL_RENDERBUFFER_BINDING);
|
||||
int renderbuffer = GL30.glGenRenderbuffers();
|
||||
try {
|
||||
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, renderbuffer);
|
||||
GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_STENCIL_INDEX8, target.width, target.height);
|
||||
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL30.GL_RENDERBUFFER, renderbuffer);
|
||||
int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
|
||||
if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
|
||||
GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL30.GL_RENDERBUFFER, 0);
|
||||
throw new IllegalStateException("Main render target is incomplete with stencil attachment: 0x" + Integer.toHexString(status));
|
||||
}
|
||||
MAIN_STENCIL_ATTACHMENTS.put(target, new Attachment(target.frameBufferId, renderbuffer, target.width, target.height));
|
||||
} catch (RuntimeException | Error exception) {
|
||||
GL30.glDeleteRenderbuffers(renderbuffer);
|
||||
throw exception;
|
||||
} finally {
|
||||
GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, previousRenderbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
private static int stencilBits() {
|
||||
int type = GL30.glGetFramebufferAttachmentParameteri(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT,
|
||||
GL30.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
|
||||
return type == GL11.GL_NONE ? 0 : GL30.glGetFramebufferAttachmentParameteri(GL30.GL_FRAMEBUFFER,
|
||||
GL30.GL_STENCIL_ATTACHMENT, GL30.GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE);
|
||||
}
|
||||
|
||||
private record Attachment(int framebuffer, int renderbuffer, int width, int height) {
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public interface PortalTerrain {
|
||||
static boolean canView(Minecraft minecraft, Vec3 exitCenter) {
|
||||
return SodiumCompat.isLoaded()
|
||||
? com.craisinlord.antarchy.content.client.renderer.sodium.SodiumPortalTerrain.canView(minecraft, exitCenter)
|
||||
: PortalGunPortalSectionViews.canView(minecraft, exitCenter);
|
||||
}
|
||||
|
||||
static PortalTerrain prepare(Minecraft minecraft, java.util.UUID exitId, Vec3 exitCenter, Vec3 exitNormal, Frustum frustum) {
|
||||
return SodiumCompat.isLoaded()
|
||||
? com.craisinlord.antarchy.content.client.renderer.sodium.SodiumPortalTerrain.prepare(minecraft, frustum)
|
||||
: VanillaPortalTerrain.prepare(minecraft, exitId, exitCenter, exitNormal, frustum);
|
||||
}
|
||||
|
||||
int sectionCount();
|
||||
|
||||
void begin(Minecraft minecraft);
|
||||
|
||||
void end(Minecraft minecraft);
|
||||
|
||||
void drawLayer(Minecraft minecraft, RenderType renderType, Vec3 cameraPosition, Matrix4f viewMatrix, Matrix4f projection);
|
||||
|
||||
void forEachBlockEntity(Minecraft minecraft, Frustum frustum, Consumer<BlockEntity> consumer);
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class RoyalBeamRenderTypes extends RenderType {
|
||||
public RoyalBeamRenderTypes(String name, VertexFormat format, VertexFormat.Mode mode, int bufferSize,
|
||||
boolean affectsCrumbling, boolean sortOnUpload, Runnable setupState, Runnable clearState) {
|
||||
super(name, format, mode, bufferSize, affectsCrumbling, sortOnUpload, setupState, clearState);
|
||||
}
|
||||
|
||||
public static RenderType beam(ResourceLocation texture) {
|
||||
return create("tremorzilla_beam", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(texture, false, false))
|
||||
.setShaderState(RenderStateShard.RENDERTYPE_ENERGY_SWIRL_SHADER)
|
||||
.setTransparencyState(RenderStateShard.TRANSLUCENT_TRANSPARENCY)
|
||||
.setCullState(RenderStateShard.NO_CULL)
|
||||
.setLightmapState(RenderStateShard.LIGHTMAP)
|
||||
.setOutputState(RenderStateShard.ITEM_ENTITY_TARGET)
|
||||
.createCompositeState(false));
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.anthology.beam.client.BeamRenderTypes;
|
||||
import com.craisinlord.antarchy.content.client.model.RoyalBossModel;
|
||||
import com.craisinlord.antarchy.content.entity.royal.RoyalBossEntity;
|
||||
import com.craisinlord.antarchy.content.entity.royal.KingEntity;
|
||||
@@ -204,13 +205,13 @@ public class RoyalBossRenderer extends GeoEntityRenderer<RoyalBossEntity> {
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F));
|
||||
org.joml.Matrix4f pose = poseStack.last().pose();
|
||||
|
||||
VertexConsumer innerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(inner));
|
||||
VertexConsumer innerBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(inner));
|
||||
drawLocalBeam(innerBuffer, pose, length, BEAM_INNER_RADIUS, 4, innerV, 0.5F);
|
||||
VertexConsumer outerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(outer));
|
||||
VertexConsumer outerBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(outer));
|
||||
drawLocalBeam(outerBuffer, pose, length, BEAM_OUTER_RADIUS, 8, outerV, 0.15F);
|
||||
|
||||
ResourceLocation endTexture = endTextures[(entity.tickCount / 2) % endTextures.length];
|
||||
VertexConsumer endBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(endTexture));
|
||||
VertexConsumer endBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(endTexture));
|
||||
drawBeamImpact(endBuffer, pose, (float) length - 1.5F, BEAM_INNER_RADIUS);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.anthology.beam.client.BeamRenderTypes;
|
||||
import com.craisinlord.antarchy.content.client.model.RoyalMountModel;
|
||||
import com.craisinlord.antarchy.content.entity.royal.RoyalMountEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -95,12 +96,12 @@ public class RoyalMountRenderer extends GeoEntityRenderer<RoyalMountEntity> {
|
||||
poseStack.mulPose(com.mojang.math.Axis.XP.rotation((float) (-Math.PI * 0.5D + pitch)));
|
||||
poseStack.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(45.0F));
|
||||
org.joml.Matrix4f pose = poseStack.last().pose();
|
||||
VertexConsumer innerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(inner));
|
||||
VertexConsumer innerBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(inner));
|
||||
drawLocalBeam(innerBuffer, pose, length, 0.375F, 4, innerV, 0.5F);
|
||||
VertexConsumer outerBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(outer));
|
||||
VertexConsumer outerBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(outer));
|
||||
drawLocalBeam(outerBuffer, pose, length, 0.44F, 8, outerV, 0.15F);
|
||||
ResourceLocation endTexture = endTextures[(entity.tickCount / 2) % endTextures.length];
|
||||
VertexConsumer endBuffer = bufferSource.getBuffer(RoyalBeamRenderTypes.beam(endTexture));
|
||||
VertexConsumer endBuffer = bufferSource.getBuffer(BeamRenderTypes.beam(endTexture));
|
||||
RoyalBossRenderer.drawBeamImpact(endBuffer, pose, (float) length - 1.5F, 0.375F);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
public final class SodiumCompat {
|
||||
private static final String SODIUM_RENDERER_CLASS = "net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer";
|
||||
private static Boolean loaded;
|
||||
|
||||
private SodiumCompat() {
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
if (loaded == null) {
|
||||
loaded = detect();
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
|
||||
private static boolean detect() {
|
||||
String resource = SODIUM_RENDERER_CLASS.replace('.', '/') + ".class";
|
||||
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (contextLoader != null && contextLoader.getResource(resource) != null) {
|
||||
return true;
|
||||
}
|
||||
ClassLoader ownLoader = SodiumCompat.class.getClassLoader();
|
||||
return ownLoader != null && ownLoader.getResource(resource) != null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.content.client.ContractionAfterimages;
|
||||
import com.craisinlord.anthology.time.client.ContractionAfterimages;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import java.util.Deque;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.content.client.ContractionAfterimages;
|
||||
import com.craisinlord.anthology.time.client.ContractionAfterimages;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import java.util.Deque;
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class TimeDilationFieldRenderer extends EntityRenderer<TimeDilationFieldEntity> {
|
||||
public TimeDilationFieldRenderer(EntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
this.shadowRadius = 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TimeDilationFieldEntity entity, float entityYaw, float partialTick, PoseStack poseStack,
|
||||
MultiBufferSource bufferSource, int packedLight) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureLocation(TimeDilationFieldEntity entity) {
|
||||
return ResourceLocation.withDefaultNamespace("textures/misc/unknown_pack.png");
|
||||
}
|
||||
}
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer;
|
||||
|
||||
import com.craisinlord.antarchy.content.client.PortalGunPortalRenderState;
|
||||
import com.craisinlord.antarchy.mixins.client.LevelRendererPortalViewAreaAccessor;
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.chunk.RenderRegionCache;
|
||||
import net.minecraft.client.renderer.chunk.SectionRenderDispatcher;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
final class VanillaPortalTerrain implements PortalTerrain {
|
||||
private static final int MAX_REBUILDS_PER_SCENE = 32;
|
||||
|
||||
private final ObjectArrayList<SectionRenderDispatcher.RenderSection> sections;
|
||||
|
||||
private VanillaPortalTerrain(ObjectArrayList<SectionRenderDispatcher.RenderSection> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
static VanillaPortalTerrain prepare(Minecraft minecraft, UUID exitId, Vec3 exitCenter, Vec3 exitNormal, Frustum frustum) {
|
||||
PortalGunPortalSectionViews.View view = PortalGunPortalSectionViews.prepare(minecraft, exitId, exitCenter, exitNormal, frustum);
|
||||
view.visibleSections().removeIf(section -> !PortalGunPortalRenderState.shouldRenderBounds(section.getBoundingBox()));
|
||||
queueDirtySections(minecraft, view.visibleSections());
|
||||
return new VanillaPortalTerrain(view.visibleSections());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sectionCount() {
|
||||
return this.sections.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Minecraft minecraft, RenderType renderType, Vec3 cameraPosition, Matrix4f viewMatrix, Matrix4f projection) {
|
||||
renderType.setupRenderState();
|
||||
ShaderInstance shader = RenderSystem.getShader();
|
||||
if (shader == null) {
|
||||
renderType.clearRenderState();
|
||||
return;
|
||||
}
|
||||
shader.setDefaultUniforms(VertexFormat.Mode.QUADS, viewMatrix, projection, minecraft.getWindow());
|
||||
shader.apply();
|
||||
Uniform chunkOffset = shader.CHUNK_OFFSET;
|
||||
boolean frontToBack = renderType != RenderType.translucent();
|
||||
ObjectListIterator<SectionRenderDispatcher.RenderSection> iterator =
|
||||
this.sections.listIterator(frontToBack ? 0 : this.sections.size());
|
||||
try {
|
||||
while (frontToBack ? iterator.hasNext() : iterator.hasPrevious()) {
|
||||
SectionRenderDispatcher.RenderSection section = frontToBack ? iterator.next() : iterator.previous();
|
||||
if (section.getCompiled().isEmpty(renderType)) {
|
||||
continue;
|
||||
}
|
||||
VertexBuffer buffer = section.getBuffer(renderType);
|
||||
BlockPos origin = section.getOrigin();
|
||||
if (chunkOffset != null) {
|
||||
chunkOffset.set((float) (origin.getX() - cameraPosition.x), (float) (origin.getY() - cameraPosition.y),
|
||||
(float) (origin.getZ() - cameraPosition.z));
|
||||
chunkOffset.upload();
|
||||
}
|
||||
buffer.bind();
|
||||
buffer.draw();
|
||||
}
|
||||
} finally {
|
||||
if (chunkOffset != null) {
|
||||
chunkOffset.set(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
shader.clear();
|
||||
VertexBuffer.unbind();
|
||||
renderType.clearRenderState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachBlockEntity(Minecraft minecraft, Frustum frustum, Consumer<BlockEntity> consumer) {
|
||||
for (SectionRenderDispatcher.RenderSection section : this.sections) {
|
||||
for (BlockEntity blockEntity : section.getCompiled().getRenderableBlockEntities()) {
|
||||
consumer.accept(blockEntity);
|
||||
}
|
||||
}
|
||||
LevelRendererPortalViewAreaAccessor state = (LevelRendererPortalViewAreaAccessor) minecraft.levelRenderer;
|
||||
synchronized (state.antarchy$getGlobalBlockEntities()) {
|
||||
for (BlockEntity blockEntity : state.antarchy$getGlobalBlockEntities()) {
|
||||
if (frustum.isVisible(new AABB(blockEntity.getBlockPos()).inflate(1.0D))) {
|
||||
consumer.accept(blockEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void queueDirtySections(Minecraft minecraft, ObjectArrayList<SectionRenderDispatcher.RenderSection> sections) {
|
||||
SectionRenderDispatcher dispatcher = minecraft.levelRenderer.getSectionRenderDispatcher();
|
||||
if (dispatcher == null) {
|
||||
return;
|
||||
}
|
||||
RenderRegionCache cache = null;
|
||||
int queued = 0;
|
||||
for (SectionRenderDispatcher.RenderSection section : sections) {
|
||||
if (queued >= MAX_REBUILDS_PER_SCENE) {
|
||||
break;
|
||||
}
|
||||
if (!section.isDirty() || !minecraft.level.getLightEngine().lightOnInSection(SectionPos.of(section.getOrigin()))) {
|
||||
continue;
|
||||
}
|
||||
if (cache == null) {
|
||||
cache = new RenderRegionCache();
|
||||
}
|
||||
section.rebuildSectionAsync(dispatcher, cache);
|
||||
section.setNotDirty();
|
||||
queued++;
|
||||
}
|
||||
}
|
||||
}
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.client.renderer.sodium;
|
||||
|
||||
import com.craisinlord.antarchy.content.client.PortalGunPortalRenderState;
|
||||
import com.craisinlord.antarchy.content.client.renderer.PortalTerrain;
|
||||
import com.craisinlord.antarchy.mixins.compat.sodium.RenderSectionManagerAccessor;
|
||||
import com.craisinlord.antarchy.mixins.compat.sodium.SodiumWorldRendererAccessor;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import net.caffeinemc.mods.sodium.client.SodiumClientMod;
|
||||
import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice;
|
||||
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSection;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.TaskQueueType;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.lists.CoordinateSectionVisitor;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.lists.SortedRenderLists;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.lists.TreeSectionCollector;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
|
||||
import net.caffeinemc.mods.sodium.client.render.viewport.Viewport;
|
||||
import net.caffeinemc.mods.sodium.client.render.viewport.ViewportProvider;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public final class SodiumPortalTerrain implements PortalTerrain {
|
||||
private static final int FIRST_PORTAL_FRAME = -1_000_000;
|
||||
private static final int MAX_PENDING_TASKS_PER_QUEUE = 256;
|
||||
private static final Map<TaskQueueType, ArrayDeque<RenderSection>> PENDING_TASKS = new EnumMap<>(TaskQueueType.class);
|
||||
private static int nextFrame = FIRST_PORTAL_FRAME;
|
||||
|
||||
private final SodiumWorldRenderer worldRenderer;
|
||||
private final RenderSectionManager sectionManager;
|
||||
private final SortedRenderLists renderLists;
|
||||
private final int sectionCount;
|
||||
private SortedRenderLists previousRenderLists;
|
||||
private boolean previousEntityCulling;
|
||||
|
||||
private SodiumPortalTerrain(SodiumWorldRenderer worldRenderer, RenderSectionManager sectionManager, SortedRenderLists renderLists, int sectionCount) {
|
||||
this.worldRenderer = worldRenderer;
|
||||
this.sectionManager = sectionManager;
|
||||
this.renderLists = renderLists;
|
||||
this.sectionCount = sectionCount;
|
||||
}
|
||||
|
||||
public static boolean canView(Minecraft minecraft, Vec3 exitCenter) {
|
||||
SodiumWorldRenderer worldRenderer = SodiumWorldRenderer.instanceNullable();
|
||||
if (worldRenderer == null || minecraft.player == null
|
||||
|| ((SodiumWorldRendererAccessor) worldRenderer).antarchy$getRenderSectionManager() == null) {
|
||||
return false;
|
||||
}
|
||||
int limit = minecraft.options.getEffectiveRenderDistance();
|
||||
return Math.abs(SectionPos.posToSectionCoord(exitCenter.x) - minecraft.player.chunkPosition().x) <= limit
|
||||
&& Math.abs(SectionPos.posToSectionCoord(exitCenter.z) - minecraft.player.chunkPosition().z) <= limit;
|
||||
}
|
||||
|
||||
public static PortalTerrain prepare(Minecraft minecraft, Frustum frustum) {
|
||||
SodiumWorldRenderer worldRenderer = SodiumWorldRenderer.instanceNullable();
|
||||
RenderSectionManager sectionManager = worldRenderer == null ? null
|
||||
: ((SodiumWorldRendererAccessor) worldRenderer).antarchy$getRenderSectionManager();
|
||||
if (sectionManager == null) {
|
||||
return EmptyTerrain.INSTANCE;
|
||||
}
|
||||
RenderSectionManagerAccessor manager = (RenderSectionManagerAccessor) sectionManager;
|
||||
int frame = nextFrame--;
|
||||
if (nextFrame > FIRST_PORTAL_FRAME) {
|
||||
nextFrame = FIRST_PORTAL_FRAME;
|
||||
}
|
||||
Viewport viewport = ((ViewportProvider) frustum).sodium$createViewport();
|
||||
TreeSectionCollector collector = new TreeSectionCollector(frame,
|
||||
SodiumClientMod.options().performance.chunkBuildDeferMode.getImportantRebuildQueueType(),
|
||||
manager.antarchy$getSortBehavior().getDeferMode().getImportantRebuildQueueType(),
|
||||
manager.antarchy$getSectionByPosition());
|
||||
int[] visited = {0};
|
||||
CoordinateSectionVisitor apertureFilter = (x, y, z) -> {
|
||||
int minX = SectionPos.sectionToBlockCoord(x);
|
||||
int minY = SectionPos.sectionToBlockCoord(y);
|
||||
int minZ = SectionPos.sectionToBlockCoord(z);
|
||||
if (PortalGunPortalRenderState.shouldRenderBounds(new AABB(minX, minY, minZ, minX + 16, minY + 16, minZ + 16))) {
|
||||
collector.visit(x, y, z);
|
||||
visited[0]++;
|
||||
}
|
||||
};
|
||||
manager.antarchy$getRenderableSectionTree().prepareForTraversal();
|
||||
manager.antarchy$getRenderableSectionTree().traverse(apertureFilter, viewport, manager.antarchy$getSearchDistance());
|
||||
SortedRenderLists renderLists = collector.createRenderLists(viewport);
|
||||
stashPendingTasks(collector.getTaskLists());
|
||||
sectionManager.markGraphDirty();
|
||||
return new SodiumPortalTerrain(worldRenderer, sectionManager, renderLists, visited[0]);
|
||||
}
|
||||
|
||||
public static void drainPendingTasks(Map<TaskQueueType, ArrayDeque<RenderSection>> taskLists) {
|
||||
if (PENDING_TASKS.isEmpty() || taskLists == null) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<TaskQueueType, ArrayDeque<RenderSection>> entry : PENDING_TASKS.entrySet()) {
|
||||
ArrayDeque<RenderSection> queue = taskLists.get(entry.getKey());
|
||||
if (queue == null) {
|
||||
continue;
|
||||
}
|
||||
int limit = entry.getKey().queueSizeLimit();
|
||||
for (RenderSection section : entry.getValue()) {
|
||||
if (queue.size() >= limit) {
|
||||
break;
|
||||
}
|
||||
if (!section.isDisposed() && section.getPendingUpdate() != 0 && section.getRunningJob() == null) {
|
||||
queue.add(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
PENDING_TASKS.clear();
|
||||
}
|
||||
|
||||
private static void stashPendingTasks(Map<TaskQueueType, ArrayDeque<RenderSection>> taskLists) {
|
||||
for (Map.Entry<TaskQueueType, ArrayDeque<RenderSection>> entry : taskLists.entrySet()) {
|
||||
if (entry.getValue().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ArrayDeque<RenderSection> pending = PENDING_TASKS.computeIfAbsent(entry.getKey(), type -> new ArrayDeque<>());
|
||||
for (RenderSection section : entry.getValue()) {
|
||||
if (pending.size() >= MAX_PENDING_TASKS_PER_QUEUE) {
|
||||
break;
|
||||
}
|
||||
pending.add(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sectionCount() {
|
||||
return this.sectionCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin(Minecraft minecraft) {
|
||||
RenderSectionManagerAccessor manager = (RenderSectionManagerAccessor) this.sectionManager;
|
||||
SodiumWorldRendererAccessor renderer = (SodiumWorldRendererAccessor) this.worldRenderer;
|
||||
this.previousRenderLists = manager.antarchy$getRenderLists();
|
||||
this.previousEntityCulling = renderer.antarchy$getUseEntityCulling();
|
||||
manager.antarchy$setRenderLists(this.renderLists);
|
||||
renderer.antarchy$setUseEntityCulling(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Minecraft minecraft) {
|
||||
((RenderSectionManagerAccessor) this.sectionManager).antarchy$setRenderLists(this.previousRenderLists);
|
||||
((SodiumWorldRendererAccessor) this.worldRenderer).antarchy$setUseEntityCulling(this.previousEntityCulling);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachBlockEntity(Minecraft minecraft, Frustum frustum, Consumer<BlockEntity> consumer) {
|
||||
this.worldRenderer.iterateVisibleBlockEntities(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Minecraft minecraft, RenderType renderType, Vec3 cameraPosition, Matrix4f viewMatrix, Matrix4f projection) {
|
||||
TerrainRenderPass[] passes;
|
||||
if (renderType == RenderType.solid()) {
|
||||
passes = new TerrainRenderPass[] {DefaultTerrainRenderPasses.SOLID, DefaultTerrainRenderPasses.CUTOUT};
|
||||
} else if (renderType == RenderType.translucent()) {
|
||||
passes = new TerrainRenderPass[] {DefaultTerrainRenderPasses.TRANSLUCENT};
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
ChunkRenderMatrices matrices = new ChunkRenderMatrices(projection, viewMatrix);
|
||||
RenderDevice.enterManagedCode();
|
||||
try {
|
||||
for (TerrainRenderPass pass : passes) {
|
||||
this.sectionManager.renderLayer(matrices, pass, cameraPosition.x, cameraPosition.y, cameraPosition.z);
|
||||
}
|
||||
} finally {
|
||||
RenderDevice.exitManagedCode();
|
||||
}
|
||||
}
|
||||
|
||||
private enum EmptyTerrain implements PortalTerrain {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public int sectionCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Minecraft minecraft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Minecraft minecraft, RenderType renderType, Vec3 cameraPosition, Matrix4f viewMatrix, Matrix4f projection) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachBlockEntity(Minecraft minecraft, Frustum frustum, Consumer<BlockEntity> consumer) {
|
||||
}
|
||||
}
|
||||
}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.command;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public final class GravityCommand {
|
||||
private static final AntarchyGravityTransition COMMAND_TRANSITION = new AntarchyGravityTransition(12);
|
||||
|
||||
private GravityCommand() {
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
dispatcher.register(
|
||||
Commands.literal("gravity")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.then(Commands.literal("get")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.executes(context -> getGravity(context, EntityArgument.getEntities(context, "targets")))))
|
||||
.then(Commands.literal("set")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.then(Commands.literal("down")
|
||||
.executes(context -> setGravity(context, EntityArgument.getEntities(context, "targets"), AntarchyGravityDirection.DOWN)))
|
||||
.then(Commands.literal("up")
|
||||
.executes(context -> setGravity(context, EntityArgument.getEntities(context, "targets"), AntarchyGravityDirection.UP)))))
|
||||
.then(Commands.literal("clear")
|
||||
.then(Commands.argument("targets", EntityArgument.entities())
|
||||
.executes(context -> clearGravity(context, EntityArgument.getEntities(context, "targets")))))
|
||||
);
|
||||
}
|
||||
|
||||
private static int getGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(target);
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal(target.getName().getString() + ": " + direction.getSerializedName()),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int setGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets, AntarchyGravityDirection direction) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityApi.setGravityDirection(target, direction, COMMAND_TRANSITION);
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal("Set gravity " + direction.getSerializedName() + " for " + targets.size() + " target(s)"),
|
||||
true
|
||||
);
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int clearGravity(CommandContext<CommandSourceStack> context, Collection<? extends Entity> targets) {
|
||||
for (Entity target : targets) {
|
||||
AntarchyGravityApi.setGravityDirection(target, AntarchyGravityDirection.DOWN, COMMAND_TRANSITION);
|
||||
}
|
||||
|
||||
context.getSource().sendSuccess(
|
||||
() -> Component.literal("Reset gravity for " + targets.size() + " target(s)"),
|
||||
true
|
||||
);
|
||||
return targets.size();
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.effect;
|
||||
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public final class ContractedMobEffect extends MobEffect {
|
||||
public static final double RATE = 2.0D;
|
||||
public static final double STRONG_RATE = 3.0D;
|
||||
|
||||
public ContractedMobEffect() {
|
||||
super(MobEffectCategory.BENEFICIAL, 0xD5A63A);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static double rateForAmplifier(int amplifier) {
|
||||
return amplifier > 0 ? STRONG_RATE : RATE;
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.effect;
|
||||
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public final class DilatedMobEffect extends MobEffect {
|
||||
public static final double RATE = 0.35D;
|
||||
public static final double STRONG_RATE = 0.2D;
|
||||
|
||||
public DilatedMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, 0x6C4AB6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static double rateForAmplifier(int amplifier) {
|
||||
return amplifier > 0 ? STRONG_RATE : RATE;
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.effect;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
public final class InvertedMobEffect extends MobEffect {
|
||||
private static final AntarchyGravityTransition EFFECT_TRANSITION = new AntarchyGravityTransition(12);
|
||||
|
||||
public InvertedMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, 0x8B0000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
// Vex flight steering is authored around vanilla gravity and ground contact. Rotating its
|
||||
// gravity frame makes the native flight controller drive it into terrain.
|
||||
if (entity.getType() == EntityType.VEX) {
|
||||
if (!entity.level().isClientSide()) {
|
||||
AntarchyGravityApi.clearForcedGravity(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!entity.level().isClientSide()) {
|
||||
if (AntarchyGravityApi.getGravityDirection(entity) != AntarchyGravityDirection.UP || !AntarchyGravityApi.isGravityForced(entity)) {
|
||||
AntarchyGravityApi.setForcedGravityDirection(entity, AntarchyGravityDirection.UP, EFFECT_TRANSITION);
|
||||
}
|
||||
} else {
|
||||
// Mob effects are synced by vanilla, so this fires on the client too.
|
||||
// If the gravity state hasn't been applied yet , apply it directly without position adjustment.
|
||||
if (!AntarchyGravityApi.isGravityInverted(entity)) {
|
||||
AntarchyGravityApi.applySyncedState(entity, AntarchyGravityDirection.UP, AntarchyGravityDirection.UP, true, 0, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-6
@@ -1,5 +1,6 @@
|
||||
package com.craisinlord.antarchy.content.effect;
|
||||
|
||||
import com.craisinlord.anthology.effect.AnthologyEffects;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -11,10 +12,6 @@ import net.minecraft.world.effect.MobEffect;
|
||||
public final class RoyalEffectHooks {
|
||||
private static final ResourceKey<MobEffect> COMMANDED_KEY = ResourceKey.create(Registries.MOB_EFFECT,
|
||||
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "commanded"));
|
||||
private static final ResourceKey<MobEffect> DILATED_KEY = ResourceKey.create(Registries.MOB_EFFECT,
|
||||
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "dilated"));
|
||||
private static final ResourceKey<MobEffect> CONTRACTED_KEY = ResourceKey.create(Registries.MOB_EFFECT,
|
||||
ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "contracted"));
|
||||
|
||||
private RoyalEffectHooks() {
|
||||
}
|
||||
@@ -24,10 +21,10 @@ public final class RoyalEffectHooks {
|
||||
}
|
||||
|
||||
public static Holder<MobEffect> dilatedHolder() {
|
||||
return BuiltInRegistries.MOB_EFFECT.getHolder(DILATED_KEY).orElse(null);
|
||||
return AnthologyEffects.dilated();
|
||||
}
|
||||
|
||||
public static Holder<MobEffect> contractedHolder() {
|
||||
return BuiltInRegistries.MOB_EFFECT.getHolder(CONTRACTED_KEY).orElse(null);
|
||||
return AnthologyEffects.contracted();
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -477,15 +477,15 @@ public class AlphaMantisEntity extends MantisEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -334,16 +334,16 @@ public abstract class AppleCowEntity extends Cow implements GeoEntity, Shearable
|
||||
this.setDeltaMovement(this.toWorld(0.0D, motion.y < 0.0D ? motion.y : 0.0D, 0.0D));
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private int randomNapCooldown() {
|
||||
|
||||
+6
-6
@@ -5,9 +5,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.block.BedBugEggBlock;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -394,15 +394,15 @@ public class BedBugEntity extends Animal implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -352,16 +352,16 @@ public class BomberEntity extends Monster implements GeoEntity {
|
||||
return this.toLocal(this.getDeltaMovement()).horizontalDistanceSqr() > 1.0E-4D || this.getNavigation().isInProgress();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
@@ -184,7 +184,7 @@ public class ButterflyEntity extends Animal implements FlyingAnimal, GeoEntity {
|
||||
FlyingPathNavigation navigation = new FlyingPathNavigation(this, level) {
|
||||
@Override
|
||||
public boolean isStableDestination(BlockPos pos) {
|
||||
BlockPos support = AntarchyGravityApi.isGravityInverted(ButterflyEntity.this) ? pos.above() : pos.below();
|
||||
BlockPos support = GravityApi.isGravityInverted(ButterflyEntity.this) ? pos.above() : pos.below();
|
||||
return !this.level.getBlockState(support).isAir();
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public class ButterflyEntity extends Animal implements FlyingAnimal, GeoEntity {
|
||||
|
||||
@Override
|
||||
protected void jumpInLiquid(net.minecraft.tags.TagKey<Fluid> fluidTag) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.01D, 0.0D, AntarchyGravityApi.getGravityDirection(this))));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 0.01D, 0.0D, GravityApi.getGravityDirection(this))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
@@ -228,16 +228,16 @@ public class CrawlingBlightEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -768,20 +768,20 @@ public class DorrieEntity extends Animal implements GeoEntity {
|
||||
|| this.getNavigation().isInProgress();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+23
-23
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -428,9 +428,9 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
case ACTIVE -> {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 motion = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 motion = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
if (--this.hardenDurationTicks <= 0) {
|
||||
this.beginHardeningEnd();
|
||||
return;
|
||||
@@ -441,9 +441,9 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
case END -> {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 motion = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 motion = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, motion.y, 0.0D, direction));
|
||||
if (--this.hardenStateTicks <= 0) {
|
||||
this.setHardenPhase(HardenPhase.NONE);
|
||||
this.hardenCooldownTicks = Math.max(1, AntarchySettings.emperorScorpionHardenCooldownTicks());
|
||||
@@ -504,10 +504,10 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
Vec3 anchor = this.getTarget() != null ? this.getTarget().position() : this.position();
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localRing = Vec3.directionFromRotation(0.0F, this.random.nextFloat() * 360.0F)
|
||||
.scale(2.75D + this.random.nextDouble() * 1.75D);
|
||||
Vec3 worldRing = AntarchyGravityRotationUtil.vecPlayerToWorld(localRing, direction);
|
||||
Vec3 worldRing = GravityRotationUtil.vecPlayerToWorld(localRing, direction);
|
||||
BlockPos spawnPos = this.findSummonSpawnPos(anchor.add(worldRing));
|
||||
Vec3 spawnCenter = Vec3.atCenterOf(spawnPos);
|
||||
scorpion.moveTo(spawnCenter.x, spawnCenter.y, spawnCenter.z, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
@@ -522,22 +522,22 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
private BlockPos findSummonSpawnPos(Vec3 center) {
|
||||
BlockPos base = BlockPos.containing(center);
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityUp = gravityDown.getOpposite();
|
||||
BlockPos fallback = base;
|
||||
for (int step = -2; step <= 2; step++) {
|
||||
@@ -1001,10 +1001,10 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
|
||||
if (EmperorScorpionEntity.this.isWithinMeleeAttackRange(target) && EmperorScorpionEntity.this.hasLineOfSight(target)) {
|
||||
EmperorScorpionEntity.this.getNavigation().stop();
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localMotion = GravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
Vec3 localStopped = new Vec3(0.0D, localMotion.y, 0.0D);
|
||||
Vec3 worldStopped = AntarchyGravityRotationUtil.vecPlayerToWorld(localStopped, direction);
|
||||
Vec3 worldStopped = GravityRotationUtil.vecPlayerToWorld(localStopped, direction);
|
||||
EmperorScorpionEntity.this.setDeltaMovement(worldStopped);
|
||||
AttackType attackType = EmperorScorpionEntity.this.selectAttack(target);
|
||||
if (attackType != AttackType.NONE) {
|
||||
@@ -1024,8 +1024,8 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void approachDirectly(LivingEntity target) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(EmperorScorpionEntity.this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(EmperorScorpionEntity.this);
|
||||
Vec3 localDelta = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(EmperorScorpionEntity.this.position()), direction);
|
||||
double dx = localDelta.x;
|
||||
double dz = localDelta.z;
|
||||
if (dx * dx + dz * dz < 1.0E-4D) {
|
||||
@@ -1039,15 +1039,15 @@ public class EmperorScorpionEntity extends Monster implements GeoEntity {
|
||||
EmperorScorpionEntity.this.yBodyRot = newYaw;
|
||||
EmperorScorpionEntity.this.yBodyRotO = newYaw;
|
||||
|
||||
Vec3 currentMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
Vec3 currentMotion = GravityRotationUtil.vecWorldToPlayer(EmperorScorpionEntity.this.getDeltaMovement(), direction);
|
||||
float headingError = Math.abs(Mth.wrapDegrees(targetYaw - currentYaw));
|
||||
if (headingError <= DIRECT_APPROACH_ALIGN_THRESHOLD) {
|
||||
double speed = EmperorScorpionEntity.this.getAttributeValue(Attributes.MOVEMENT_SPEED) * CHASE_SPEED;
|
||||
Vec3 forward = Vec3.directionFromRotation(0.0F, newYaw).scale(speed);
|
||||
Vec3 worldForward = AntarchyGravityRotationUtil.vecPlayerToWorld(forward.x, currentMotion.y, forward.z, direction);
|
||||
Vec3 worldForward = GravityRotationUtil.vecPlayerToWorld(forward.x, currentMotion.y, forward.z, direction);
|
||||
EmperorScorpionEntity.this.setDeltaMovement(worldForward);
|
||||
} else {
|
||||
EmperorScorpionEntity.this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, currentMotion.y, 0.0D, direction));
|
||||
EmperorScorpionEntity.this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(0.0D, currentMotion.y, 0.0D, direction));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchyGameRules;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.item.BigBerthaItem;
|
||||
import com.craisinlord.antarchy.content.network.HerculesBeetleImpactShakeSync;
|
||||
import java.util.EnumSet;
|
||||
@@ -1341,20 +1341,20 @@ public class HerculesBeetleEntity extends TamableAnimal implements GeoEntity, Fl
|
||||
.toList();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+8
-8
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.mixins.LivingEntityJumpingAccessor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -70,7 +70,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effectInstance) {
|
||||
return effectInstance.getEffect().value() instanceof com.craisinlord.antarchy.content.effect.InvertedMobEffect;
|
||||
return effectInstance.getEffect().value() instanceof com.craisinlord.anthology.effect.InvertedMobEffect;
|
||||
}
|
||||
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
@@ -172,11 +172,11 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
if (!this.hasPassenger(passenger)) {
|
||||
return;
|
||||
}
|
||||
Vec3 riderOffset = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 riderOffset = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
RIDER_Y_OFFSET,
|
||||
0.0D,
|
||||
AntarchyGravityApi.getGravityDirection(this)
|
||||
GravityApi.getGravityDirection(this)
|
||||
);
|
||||
moveFunction.accept(passenger, this.getX() + riderOffset.x, this.getY() + riderOffset.y, this.getZ() + riderOffset.z);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
}
|
||||
|
||||
private double resolveVerticalMotion(boolean holdingJump) {
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(this);
|
||||
double supportHeight = this.findSupportHeight(gravityDirection);
|
||||
double height = gravityDirection.isInverted() ? supportHeight - this.getY() : this.getY() - supportHeight;
|
||||
if (holdingJump) {
|
||||
@@ -236,7 +236,7 @@ public class HoverboardEntity extends PathfinderMob implements GeoEntity {
|
||||
return -SETTLE_DESCEND_SPEED;
|
||||
}
|
||||
|
||||
private double findSupportHeight(AntarchyGravityDirection gravityDirection) {
|
||||
private double findSupportHeight(GravityDirection gravityDirection) {
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ()));
|
||||
if (!gravityDirection.isInverted()) {
|
||||
int minY = this.level().getMinBuildHeight();
|
||||
|
||||
+7
-7
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.horde.CavarynHordeManager;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -308,16 +308,16 @@ public class JerryEntity extends Monster implements GeoEntity {
|
||||
: super.doHurtTarget(target);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.entity.royal.QueenEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -385,7 +385,7 @@ public class ManticoreEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private static Vec3 oppositeGravity(Entity entity) {
|
||||
return AntarchyGravityApi.isGravityInverted(entity) ? new Vec3(0.0D, -1.0D, 0.0D) : new Vec3(0.0D, 1.0D, 0.0D);
|
||||
return GravityApi.isGravityInverted(entity) ? new Vec3(0.0D, -1.0D, 0.0D) : new Vec3(0.0D, 1.0D, 0.0D);
|
||||
}
|
||||
|
||||
private void tickQueenSummonInversionRule() {
|
||||
@@ -395,8 +395,8 @@ public class ManticoreEntity extends Monster implements GeoEntity {
|
||||
if (this.hasEffect(AntarchyObjects.INVERTED_EFFECT.get())) {
|
||||
this.removeEffect(AntarchyObjects.INVERTED_EFFECT.get());
|
||||
}
|
||||
if (AntarchyGravityApi.isGravityInverted(this) && AntarchyGravityApi.isGravityForced(this)) {
|
||||
AntarchyGravityApi.setGravityDirection(this, AntarchyGravityDirection.DOWN, false);
|
||||
if (GravityApi.isGravityInverted(this) && GravityApi.isGravityForced(this)) {
|
||||
GravityApi.setGravityDirection(this, GravityDirection.DOWN, false);
|
||||
}
|
||||
this.setNoGravity(false);
|
||||
}
|
||||
|
||||
+11
-11
@@ -3,10 +3,10 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.entity.kraken.KrakenEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -413,8 +413,8 @@ public class MissileSquidEntity extends Monster implements GeoEntity {
|
||||
this.launchOwnerUuid = owner != null ? owner.getUUID() : null;
|
||||
this.setTarget(null);
|
||||
this.setNoGravity(false);
|
||||
if (owner != null && AntarchyGravityApi.isGravityInverted(owner)) {
|
||||
AntarchyGravityApi.setAirborneGravityDirection(this, AntarchyGravityApi.getGravityDirection(owner), true, AntarchyGravityTransition.INSTANT);
|
||||
if (owner != null && GravityApi.isGravityInverted(owner)) {
|
||||
GravityApi.setAirborneGravityDirection(this, GravityApi.getGravityDirection(owner), true, GravityTransition.INSTANT);
|
||||
}
|
||||
this.setDeltaMovement(velocity);
|
||||
this.hasImpulse = true;
|
||||
@@ -732,20 +732,20 @@ public class MissileSquidEntity extends Monster implements GeoEntity {
|
||||
this.setAnimationState(ANIM_IDLE);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+8
-8
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -687,20 +687,20 @@ public class MolevoreEntity extends Monster implements GeoEntity {
|
||||
return forward.normalize().dot(toTarget.normalize()) >= minimumDot;
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
Vec3 local = AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
Vec3 local = GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return new Vec3(local.x, 0.0D, local.z);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -357,12 +357,12 @@ public class OctopusBombEntity extends Monster implements GeoEntity {
|
||||
public void launchAsExplosiveProjectile(net.minecraft.world.entity.Entity launcher, Vec3 velocity) {
|
||||
this.explosiveImpact = true;
|
||||
this.explosiveLauncherId = launcher != null ? launcher.getUUID() : null;
|
||||
if (launcher != null && com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.isGravityInverted(launcher)) {
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.setAirborneGravityDirection(
|
||||
if (launcher != null && com.craisinlord.anthology.gravity.GravityApi.isGravityInverted(launcher)) {
|
||||
com.craisinlord.anthology.gravity.GravityApi.setAirborneGravityDirection(
|
||||
this,
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityApi.getGravityDirection(launcher),
|
||||
com.craisinlord.anthology.gravity.GravityApi.getGravityDirection(launcher),
|
||||
true,
|
||||
com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition.INSTANT
|
||||
com.craisinlord.anthology.gravity.GravityTransition.INSTANT
|
||||
);
|
||||
}
|
||||
this.setDeltaMovement(velocity);
|
||||
|
||||
+6
-6
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -245,12 +245,12 @@ public class OuranwoodDeerEntity extends Animal implements GeoEntity {
|
||||
return MIN_QUIRK_COOLDOWN + this.random.nextInt(MAX_QUIRK_COOLDOWN - MIN_QUIRK_COOLDOWN + 1);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-12
@@ -7,10 +7,9 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.fluid.AntarchyFluidChecks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.movement.DreamSandLowGravityAccess;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -659,12 +658,9 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
if (this.isPlayerInsideAntiwater(focus)) {
|
||||
return false;
|
||||
}
|
||||
if (focus instanceof DreamSandLowGravityAccess access && access.antarchy$getDreamSandLandingGraceTicks() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AntarchyGravityDirection gravityDirection = AntarchyGravityApi.getGravityDirection(focus);
|
||||
Vec3 localMotion = AntarchyGravityRotationUtil.vecWorldToPlayer(focus.getDeltaMovement(), gravityDirection);
|
||||
GravityDirection gravityDirection = GravityApi.getGravityDirection(focus);
|
||||
Vec3 localMotion = GravityRotationUtil.vecWorldToPlayer(focus.getDeltaMovement(), gravityDirection);
|
||||
double descentThreshold = Math.max(0.02D, this.cfgDangerousFallSpeed);
|
||||
boolean invertedGravity = gravityDirection.isInverted();
|
||||
if (invertedGravity ? localMotion.y < descentThreshold : localMotion.y > -descentThreshold) {
|
||||
@@ -1008,7 +1004,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
}
|
||||
|
||||
private int getGravitySupportDistance(Player focus, int maxDistanceBlocks) {
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(focus);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(focus);
|
||||
Direction supportFace = gravityDown.getOpposite();
|
||||
BlockPos cursor = focus.blockPosition();
|
||||
for (int distance = 1; distance <= maxDistanceBlocks; distance++) {
|
||||
@@ -1047,7 +1043,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
double radius = Mth.lerp(1.0D - orbitBlend, desiredMin * 0.35D, desiredMax * 0.85D);
|
||||
Vec3 tetherAnchor = focus.position().add(focus.getDeltaMovement().scale(0.75D));
|
||||
double angle = orbitTime * (this.getId() % 2 == 0 ? 1.0D : -1.0D);
|
||||
double verticalOffset = AntarchyGravityApi.isGravityInverted(focus) ? -2.15D : 1.15D;
|
||||
double verticalOffset = GravityApi.isGravityInverted(focus) ? -2.15D : 1.15D;
|
||||
double y = tetherAnchor.y + verticalOffset + Math.sin(orbitTime * 0.8D) * 0.2D;
|
||||
return new Vec3(
|
||||
tetherAnchor.x + Math.cos(angle) * radius,
|
||||
@@ -1057,7 +1053,7 @@ public class ReverieEntity extends PathfinderMob implements FlyingAnimal, GeoEnt
|
||||
}
|
||||
|
||||
private Vec3 getPurpleProtectTarget(Player focus) {
|
||||
double verticalOffset = AntarchyGravityApi.isGravityInverted(focus) ? -0.95D : 0.95D;
|
||||
double verticalOffset = GravityApi.isGravityInverted(focus) ? -0.95D : 0.95D;
|
||||
Vec3 tetherAnchor = focus.position().add(focus.getDeltaMovement().scale(0.85D));
|
||||
Vec3 sideOffset = Vec3.directionFromRotation(0.0F, focus.getYRot() + 90.0F).scale(0.45D);
|
||||
return new Vec3(
|
||||
|
||||
+8
-8
@@ -4,9 +4,9 @@ import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -875,20 +875,20 @@ public class RollyPollyEntity extends TamableAnimal implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+6
-6
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -229,15 +229,15 @@ public class ScorpionEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void commitLunge(LivingEntity target, double horizontalSpeed, double verticalSpeed) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
GravityDirection direction = GravityApi.getGravityDirection(this);
|
||||
Vec3 localLunge = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), direction);
|
||||
Vec3 horizontal = new Vec3(localLunge.x, 0.0D, localLunge.z);
|
||||
if (horizontal.lengthSqr() < 1.0E-4D) {
|
||||
return;
|
||||
}
|
||||
horizontal = horizontal.normalize().scale(horizontalSpeed);
|
||||
Vec3 localImpulse = new Vec3(horizontal.x, verticalSpeed, horizontal.z);
|
||||
Vec3 worldImpulse = AntarchyGravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
Vec3 worldImpulse = GravityRotationUtil.vecPlayerToWorld(localImpulse, direction);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(worldImpulse.x, worldImpulse.y, worldImpulse.z));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
+6
-6
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -235,12 +235,12 @@ public class SpitBugEntity extends Monster implements GeoEntity {
|
||||
this.playSound(AntarchySoundEvents.SPIT_BUG_SPIT.get(), 1.0F, 0.85F + this.random.nextFloat() * 0.15F);
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private final class SpitAttackGoal extends Goal {
|
||||
|
||||
+9
-9
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -412,7 +412,7 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
this.getNavigation().stop();
|
||||
this.setDeltaMovement(Vec3.ZERO);
|
||||
this.move(MoverType.SELF, Vec3.ZERO);
|
||||
this.setPos(this.getX(), AntarchyGravityApi.isGravityInverted(this) ? clingPos.getY() + 1.01D : clingPos.getY() - this.getBbHeight() - 0.01D, this.getZ());
|
||||
this.setPos(this.getX(), GravityApi.isGravityInverted(this) ? clingPos.getY() + 1.01D : clingPos.getY() - this.getBbHeight() - 0.01D, this.getZ());
|
||||
}
|
||||
|
||||
private void tickPouncing() {
|
||||
@@ -544,7 +544,7 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
return false;
|
||||
}
|
||||
double x = pos.getX() + 0.5D;
|
||||
double y = AntarchyGravityApi.isGravityInverted(this)
|
||||
double y = GravityApi.isGravityInverted(this)
|
||||
? pos.getY() + 1.01D
|
||||
: pos.getY() - this.getBbHeight() - 0.01D;
|
||||
double z = pos.getZ() + 0.5D;
|
||||
@@ -952,8 +952,8 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Direction gravityDownDirection() {
|
||||
@@ -961,11 +961,11 @@ public class SpringbugEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+3
-3
@@ -226,10 +226,10 @@ public class ToreterrorEntity extends Monster implements GeoEntity {
|
||||
super.tick();
|
||||
if (this.level().isClientSide) {
|
||||
if (this.isJumpShaking()) {
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.register(
|
||||
com.craisinlord.anthology.shake.client.CameraShake.register(
|
||||
this,
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.TORETERROR_RANGE,
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.TORETERROR_STRENGTH,
|
||||
48.0D,
|
||||
1.0F,
|
||||
this::isJumpShaking
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.block.entity.WaspNestBlockEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -331,12 +331,12 @@ public class WaspEntity extends Monster implements GeoEntity, FlyingAnimal {
|
||||
return !this.onGround();
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private void realignHitbox() {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.entity.basilisk;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartPartDefinition;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -566,7 +566,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
|
||||
private boolean shouldSwipe(LivingEntity target, FightPhase phase) {
|
||||
double horizontalDistanceSqr = new Vec3(target.getX() - this.getX(), 0.0D, target.getZ() - this.getZ()).lengthSqr();
|
||||
Vec3 localDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), AntarchyGravityApi.getGravityDirection(this));
|
||||
Vec3 localDelta = GravityRotationUtil.vecWorldToPlayer(target.position().subtract(this.position()), GravityApi.getGravityDirection(this));
|
||||
horizontalDistanceSqr = new Vec3(localDelta.x, 0.0D, localDelta.z).lengthSqr();
|
||||
boolean beneathBoss = horizontalDistanceSqr <= 16.0D && localDelta.y <= 2.0D;
|
||||
return beneathBoss || this.distanceToSqr(target) <= phase.swipeRangeSqr;
|
||||
@@ -579,7 +579,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void tickSwipe(LivingEntity target) {
|
||||
Vec3 divePoint = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 1.0D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 divePoint = target.position().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 1.0D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.getMoveControl().setWantedPosition(divePoint.x, divePoint.y, divePoint.z, 1.45D);
|
||||
|
||||
if (this.animationTicks == 8) {
|
||||
@@ -608,7 +608,7 @@ public class BrutalflyEntity extends Monster implements GeoEntity {
|
||||
dz = this.random.nextDouble() - 0.5D;
|
||||
}
|
||||
target.knockback(SWIPE_KNOCKBACK, -dx, -dz);
|
||||
target.setDeltaMovement(target.getDeltaMovement().add(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.3D, 0.0D, AntarchyGravityApi.getGravityDirection(this))));
|
||||
target.setDeltaMovement(target.getDeltaMovement().add(GravityRotationUtil.vecPlayerToWorld(0.0D, 0.3D, 0.0D, GravityApi.getGravityDirection(this))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.craisinlord.antarchy.content.entity.glimmer;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartEntityOwner;
|
||||
import com.craisinlord.anthology.multipart.MultipartEntityOwner;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
+5
-5
@@ -8,8 +8,8 @@ import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.entity.MissileSquidEntity;
|
||||
import com.craisinlord.antarchy.content.entity.OctopusBombEntity;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartEntityOwner;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartEntityOwner;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageTypes;
|
||||
|
||||
import java.util.List;
|
||||
@@ -162,18 +162,18 @@ public class KrakenEntity extends Monster implements GeoEntity, MultipartEntityO
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartLayout antarchy$getMultipartLayout() {
|
||||
public MultipartLayout anthology$getMultipartLayout() {
|
||||
return KrakenMultipartLayout.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity[] antarchy$getMultipartParts() {
|
||||
public Entity[] anthology$getMultipartParts() {
|
||||
return this.multipartParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void antarchy$setMultipartParts(@Nullable Entity[] parts) {
|
||||
public void anthology$setMultipartParts(@Nullable Entity[] parts) {
|
||||
this.multipartParts = parts;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.entity.kraken;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartPartDefinition;
|
||||
|
||||
public final class KrakenMultipartLayout implements MultipartLayout {
|
||||
public static final KrakenMultipartLayout INSTANCE = new KrakenMultipartLayout();
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class LucidEyeProjectileEntity extends ThrowableItemProjectile {
|
||||
|
||||
@Override
|
||||
protected double getDefaultGravity() {
|
||||
return 0.03D;
|
||||
return -0.03D;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart;
|
||||
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public interface MultipartEntityOwner {
|
||||
MultipartLayout antarchy$getMultipartLayout();
|
||||
|
||||
Entity[] antarchy$getMultipartParts();
|
||||
|
||||
void antarchy$setMultipartParts(Entity[] parts);
|
||||
|
||||
default Entity[] antarchy$createMultipartParts() {
|
||||
return MultipartFramework.createMultipartParts(this);
|
||||
}
|
||||
|
||||
default void antarchy$spawnMultipartParts() {
|
||||
MultipartFramework.spawnMultipartParts(this);
|
||||
}
|
||||
|
||||
default void antarchy$discardMultipartParts() {
|
||||
MultipartFramework.discardMultipartParts(this);
|
||||
}
|
||||
|
||||
default void antarchy$syncMultipartParts() {
|
||||
MultipartFramework.syncMultipartParts(this);
|
||||
}
|
||||
|
||||
default boolean antarchy$hurtMultipartPart(Entity part, DamageSource source, float amount) {
|
||||
return ((Entity) this).hurt(source, amount);
|
||||
}
|
||||
|
||||
default InteractionResult antarchy$interactMultipartPart(Entity part, Player player, Vec3 hitPosition, InteractionHand hand) {
|
||||
return ((Entity) this).interactAt(player, hitPosition, hand);
|
||||
}
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public final class MultipartFramework {
|
||||
private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(MultipartFramework.class);
|
||||
private static boolean warnedMissingFactory;
|
||||
|
||||
public interface PartFactory {
|
||||
Entity create(MultipartEntityOwner owner, int partIndex, MultipartPartDefinition spec);
|
||||
}
|
||||
|
||||
public interface NetworkBridge {
|
||||
void sendAttack(UUID parentId, int partIndex, float damage);
|
||||
|
||||
void sendInteract(UUID parentId, int partIndex, int handId);
|
||||
}
|
||||
|
||||
private static final NetworkBridge NOOP_BRIDGE = new NetworkBridge() {
|
||||
@Override
|
||||
public void sendAttack(UUID parentId, int partIndex, float damage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendInteract(UUID parentId, int partIndex, int handId) {
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
private static PartFactory partFactory;
|
||||
private static NetworkBridge networkBridge = NOOP_BRIDGE;
|
||||
private MultipartFramework() {
|
||||
}
|
||||
|
||||
public static void bootstrap(
|
||||
PartFactory partFactory,
|
||||
NetworkBridge networkBridge
|
||||
) {
|
||||
MultipartFramework.partFactory = Objects.requireNonNull(partFactory, "partFactory");
|
||||
MultipartFramework.networkBridge = Objects.requireNonNull(networkBridge, "networkBridge");
|
||||
}
|
||||
|
||||
public static Entity[] createMultipartParts(MultipartEntityOwner owner) {
|
||||
if (partFactory == null) {
|
||||
if (!warnedMissingFactory) {
|
||||
warnedMissingFactory = true;
|
||||
LOGGER.warn("Multipart part factory has not been bootstrapped on this platform; "
|
||||
+ "multipart entities will fall back to their base hitbox only");
|
||||
}
|
||||
return new Entity[0];
|
||||
}
|
||||
|
||||
MultipartLayout layout = owner.antarchy$getMultipartLayout();
|
||||
MultipartPartDefinition[] parts = layout.parts();
|
||||
Entity[] created = new Entity[parts.length];
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
created[i] = createMultipartPart(owner, i, parts[i]);
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
public static Entity createMultipartPart(MultipartEntityOwner owner, int index, MultipartPartDefinition spec) {
|
||||
PartFactory factory = partFactory;
|
||||
if (factory == null) {
|
||||
throw new IllegalStateException("Multipart part factory has not been bootstrapped");
|
||||
}
|
||||
|
||||
return factory.create(owner, index, spec);
|
||||
}
|
||||
|
||||
public static void spawnMultipartParts(MultipartEntityOwner owner) {
|
||||
Entity[] parts = owner.antarchy$getMultipartParts();
|
||||
if (parts == null) {
|
||||
parts = owner.antarchy$createMultipartParts();
|
||||
owner.antarchy$setMultipartParts(parts);
|
||||
}
|
||||
syncMultipartParts(owner);
|
||||
}
|
||||
|
||||
public static void discardMultipartParts(MultipartEntityOwner owner) {
|
||||
Entity[] parts = owner.antarchy$getMultipartParts();
|
||||
if (parts == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entity part : parts) {
|
||||
if (part != null) {
|
||||
part.discard();
|
||||
}
|
||||
}
|
||||
|
||||
owner.antarchy$setMultipartParts(null);
|
||||
}
|
||||
|
||||
public static void syncMultipartParts(MultipartEntityOwner owner) {
|
||||
Entity[] parts = owner.antarchy$getMultipartParts();
|
||||
if (parts == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entity part : parts) {
|
||||
if (part instanceof MultipartPartAccess access) {
|
||||
access.antarchy$syncFromParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMultipartAttack(UUID parentId, int partIndex, float damage) {
|
||||
networkBridge.sendAttack(parentId, partIndex, damage);
|
||||
}
|
||||
|
||||
public static void sendMultipartInteract(UUID parentId, int partIndex, int handId) {
|
||||
networkBridge.sendInteract(parentId, partIndex, handId);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public interface MultipartLayout {
|
||||
MultipartPartDefinition[] parts();
|
||||
|
||||
default MultipartPartDefinition part(int index) {
|
||||
return this.parts()[index];
|
||||
}
|
||||
|
||||
default Vec3 getPartPosition(Entity parent, MultipartPartDefinition spec) {
|
||||
double yawRadians = Math.toRadians(parent.getYRot());
|
||||
Vec3 forward = new Vec3(-Math.sin(yawRadians), 0.0D, Math.cos(yawRadians));
|
||||
Vec3 right = new Vec3(forward.z, 0.0D, -forward.x);
|
||||
|
||||
return new Vec3(
|
||||
parent.getX() + forward.x * spec.forwardOffset() + right.x * spec.lateralOffset(),
|
||||
parent.getY() + spec.yOffset(),
|
||||
parent.getZ() + forward.z * spec.forwardOffset() + right.z * spec.lateralOffset()
|
||||
);
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart;
|
||||
|
||||
public interface MultipartPartAccess {
|
||||
void antarchy$syncFromParent();
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart;
|
||||
|
||||
public record MultipartPartDefinition(
|
||||
String name,
|
||||
float width,
|
||||
float height,
|
||||
float damageMultiplier,
|
||||
double forwardOffset,
|
||||
double yOffset,
|
||||
double lateralOffset,
|
||||
boolean collisionEnabled
|
||||
) {
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart.network;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record MultipartAttackPayload(UUID parentId, int partIndex, float damage) implements CustomPacketPayload {
|
||||
public static final Type<MultipartAttackPayload> TYPE =
|
||||
new Type<>(ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "multipart_attack"));
|
||||
public static final StreamCodec<ByteBuf, MultipartAttackPayload> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8.map(UUID::fromString, UUID::toString),
|
||||
MultipartAttackPayload::parentId,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
MultipartAttackPayload::partIndex,
|
||||
ByteBufCodecs.FLOAT,
|
||||
MultipartAttackPayload::damage,
|
||||
MultipartAttackPayload::new
|
||||
);
|
||||
|
||||
@Override
|
||||
public Type<MultipartAttackPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.multipart.network;
|
||||
|
||||
import com.craisinlord.antarchy.Antarchy;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public record MultipartInteractPayload(UUID parentId, int partIndex, int handId) implements CustomPacketPayload {
|
||||
public static final Type<MultipartInteractPayload> TYPE =
|
||||
new Type<>(ResourceLocation.fromNamespaceAndPath(Antarchy.MODID, "multipart_interact"));
|
||||
public static final StreamCodec<ByteBuf, MultipartInteractPayload> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.STRING_UTF8.map(UUID::fromString, UUID::toString),
|
||||
MultipartInteractPayload::parentId,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
MultipartInteractPayload::partIndex,
|
||||
ByteBufCodecs.VAR_INT,
|
||||
MultipartInteractPayload::handId,
|
||||
MultipartInteractPayload::new
|
||||
);
|
||||
|
||||
@Override
|
||||
public Type<MultipartInteractPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -3,9 +3,9 @@ package com.craisinlord.antarchy.content.entity.nightmare;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -170,9 +170,9 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
}
|
||||
|
||||
private void updateTrackingPosition(LivingEntity target, double progress) {
|
||||
AntarchyGravityDirection targetGravity = AntarchyGravityApi.getGravityDirection(target);
|
||||
if (AntarchyGravityApi.getGravityDirection(this) != targetGravity) {
|
||||
AntarchyGravityApi.setGravityDirection(this, targetGravity);
|
||||
GravityDirection targetGravity = GravityApi.getGravityDirection(target);
|
||||
if (GravityApi.getGravityDirection(this) != targetGravity) {
|
||||
GravityApi.setGravityDirection(this, targetGravity);
|
||||
}
|
||||
Vec3 forward = target.getLookAngle().multiply(1.0D, 0.0D, 1.0D);
|
||||
if (forward.lengthSqr() < 1.0E-4D) {
|
||||
@@ -182,12 +182,12 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
forward = new Vec3(0.0D, 0.0D, 1.0D);
|
||||
}
|
||||
forward = forward.normalize();
|
||||
Vec3 localUp = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 localUp = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 1.0D, 0.0D, targetGravity);
|
||||
Vec3 right = forward.cross(localUp).normalize();
|
||||
double sideOffset = START_SIDE_OFFSET + (END_SIDE_OFFSET - START_SIDE_OFFSET) * progress;
|
||||
double backOffset = START_BACK_OFFSET + (END_BACK_OFFSET - START_BACK_OFFSET) * progress;
|
||||
Vec3 bodyCenter = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 bodyCenter = target.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, target.getBbHeight() * 0.55D, 0.0D, targetGravity));
|
||||
Vec3 desiredPos = bodyCenter
|
||||
.add(right.scale(this.approachSide * sideOffset))
|
||||
@@ -195,7 +195,7 @@ public class NightmareBiteEntity extends Entity implements GeoEntity {
|
||||
Vec3 toTarget = bodyCenter.subtract(desiredPos);
|
||||
this.setPos(desiredPos.x, desiredPos.y, desiredPos.z);
|
||||
if (toTarget.lengthSqr() > 1.0E-4D) {
|
||||
Vec3 localToTarget = AntarchyGravityRotationUtil.vecWorldToPlayer(toTarget, targetGravity);
|
||||
Vec3 localToTarget = GravityRotationUtil.vecWorldToPlayer(toTarget, targetGravity);
|
||||
float yaw = (float) Math.toDegrees(Math.atan2(localToTarget.z, localToTarget.x)) - 90.0F;
|
||||
this.setYRot(yaw);
|
||||
}
|
||||
|
||||
+18
-18
@@ -6,9 +6,9 @@ import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.boss.BossCombatUtil;
|
||||
import com.craisinlord.antarchy.content.damage.AntarchyDamageSources;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -348,10 +348,10 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
this.tickClientParticles();
|
||||
this.updateFlightRotation();
|
||||
if (this.isRoaring()) {
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.register(
|
||||
com.craisinlord.anthology.shake.client.CameraShake.register(
|
||||
this,
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.NIGHTMARE_RANGE,
|
||||
com.craisinlord.antarchy.content.client.CameraShakeClientState.NIGHTMARE_STRENGTH,
|
||||
32.0D,
|
||||
1.35F,
|
||||
this::isRoaring
|
||||
);
|
||||
}
|
||||
@@ -746,14 +746,14 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
: target.getEyePosition();
|
||||
Vec3 lunge = lungeTarget.subtract(this.getEyePosition());
|
||||
if (lunge.lengthSqr() > 1.0E-4D) {
|
||||
AntarchyGravityDirection direction = this.gravityDirection();
|
||||
Vec3 normalized = AntarchyGravityRotationUtil.vecWorldToPlayer(lunge, direction).normalize();
|
||||
GravityDirection direction = this.gravityDirection();
|
||||
Vec3 normalized = GravityRotationUtil.vecWorldToPlayer(lunge, direction).normalize();
|
||||
double verticalBoost = this.shouldUseFlyingLocomotion() ? 0.34D : 0.18D;
|
||||
Vec3 current = AntarchyGravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
Vec3 current = GravityRotationUtil.vecWorldToPlayer(this.getDeltaMovement(), direction);
|
||||
double upward = this.shouldUseFlyingLocomotion()
|
||||
? Math.max(normalized.y * verticalBoost, -0.08D)
|
||||
: normalized.y * verticalBoost;
|
||||
this.setDeltaMovement(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
this.setDeltaMovement(GravityRotationUtil.vecPlayerToWorld(
|
||||
normalized.x * 0.85D,
|
||||
current.y * 0.18D + upward,
|
||||
normalized.z * 0.85D,
|
||||
@@ -1106,26 +1106,26 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private void knockAway(LivingEntity target, double horizontalStrength, double verticalStrength) {
|
||||
AntarchyGravityDirection direction = this.gravityDirection();
|
||||
GravityDirection direction = this.gravityDirection();
|
||||
Vec3 localDirection = this.toLocalPlane(target.position().subtract(this.position()));
|
||||
if (localDirection.lengthSqr() < 1.0E-4D) localDirection = this.toLocalPlane(this.getViewVector(1.0F));
|
||||
if (localDirection.lengthSqr() < 1.0E-4D) localDirection = new Vec3(1.0D, 0.0D, 0.0D);
|
||||
Vec3 localPush = localDirection.normalize().scale(horizontalStrength);
|
||||
Vec3 worldPush = AntarchyGravityRotationUtil.vecPlayerToWorld(localPush.x, verticalStrength, localPush.z, direction);
|
||||
Vec3 worldPush = GravityRotationUtil.vecPlayerToWorld(localPush.x, verticalStrength, localPush.z, direction);
|
||||
target.push(worldPush.x, worldPush.y, worldPush.z);
|
||||
target.hurtMarked = true;
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
@@ -1174,7 +1174,7 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private boolean tryBreakBlocksToTarget(LivingEntity target) {
|
||||
Direction gravityDown = AntarchyGravityRotationUtil.getGravityDownDirection(this);
|
||||
Direction gravityDown = GravityRotationUtil.getGravityDownDirection(this);
|
||||
BlockPos.MutableBlockPos cursor = this.blockPosition().mutable();
|
||||
for (int i = 0; i <= 16; i++) {
|
||||
if (this.level().getBlockState(cursor).is(AntarchyTags.Blocks.NIGHTMARE_BREAKABLE)) {
|
||||
@@ -1336,7 +1336,7 @@ public class NightmareEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
|
||||
private boolean isTooCloseToCeiling() {
|
||||
Direction gravityUp = AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite();
|
||||
Direction gravityUp = GravityRotationUtil.getGravityDownDirection(this).getOpposite();
|
||||
BlockPos current = this.blockPosition();
|
||||
for (int i = 1; i <= FLIGHT_CEILING_CLEARANCE_BLOCKS; i++) {
|
||||
if (!this.level().isEmptyBlock(current.relative(gravityUp, i))) return true;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.entity.nightmare;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartPartDefinition;
|
||||
|
||||
public final class NightmareMultipartLayout implements MultipartLayout {
|
||||
public static final NightmareMultipartLayout INSTANCE = new NightmareMultipartLayout();
|
||||
|
||||
+25
-25
@@ -5,8 +5,8 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectEligibility;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectHooks;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.network.KingJudgmentFlashSync;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -53,8 +53,8 @@ import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamSettings;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamTerrainMode;
|
||||
import com.craisinlord.anthology.beam.BeamSettings;
|
||||
import com.craisinlord.anthology.beam.BeamTerrainMode;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
|
||||
import com.craisinlord.antarchy.content.menu.RoyalJudgmentMenu;
|
||||
import com.craisinlord.antarchy.content.menu.RoyalJudgmentState;
|
||||
@@ -398,8 +398,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
protected SoundEvent royalBeamEndSound() { return AntarchySoundEvents.KING_BEAM_SHOOT.get(); }
|
||||
|
||||
@Override
|
||||
protected RoyalBeamSettings royalBeamSettings() {
|
||||
return new RoyalBeamSettings(AntarchySettings.kingBeamRange(), AntarchySettings.kingBeamTracking(), 7.5D,
|
||||
protected BeamSettings royalBeamSettings() {
|
||||
return new BeamSettings(AntarchySettings.kingBeamRange(), AntarchySettings.kingBeamTracking(), 7.5D,
|
||||
AntarchySettings.kingBeamDurationTicks(), AntarchySettings.kingBeamTravelTicks(), AntarchySettings.kingBeamCooldownTicks(), 6.0F, 6.0F,
|
||||
(float) AntarchySettings.kingBeamDamage(), 1.0F, 3, 100.0D,
|
||||
(float) AntarchySettings.kingBeamTerrainRadius(), 4.0F, AntarchySettings.kingBeamTerrainCap(),
|
||||
@@ -407,8 +407,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoyalBeamTerrainMode royalBeamTerrainMode() {
|
||||
return RoyalBeamTerrainMode.BUILD_ICE;
|
||||
protected BeamTerrainMode royalBeamTerrainMode() {
|
||||
return BeamTerrainMode.BUILD_ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -422,8 +422,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoyalBeamTerrainMode royalBeamTerrainMode(@Nullable RoyalHead head) {
|
||||
return head != null && head.slot() == RoyalHead.Slot.RIGHT ? RoyalBeamTerrainMode.BUILD_ICE : RoyalBeamTerrainMode.NONE;
|
||||
protected BeamTerrainMode royalBeamTerrainMode(@Nullable RoyalHead head) {
|
||||
return head != null && head.slot() == RoyalHead.Slot.RIGHT ? BeamTerrainMode.BUILD_ICE : BeamTerrainMode.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -821,8 +821,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
this.setRoyalFlying(true);
|
||||
this.getMoveControl().setWantedPosition(landing.x, landing.y, landing.z, 1.35D);
|
||||
this.tickKingLandingIndicator();
|
||||
Vec3 localLandingDelta = AntarchyGravityRotationUtil.vecWorldToPlayer(
|
||||
this.position().subtract(landing), AntarchyGravityApi.getGravityDirection(this));
|
||||
Vec3 localLandingDelta = GravityRotationUtil.vecWorldToPlayer(
|
||||
this.position().subtract(landing), GravityApi.getGravityDirection(this));
|
||||
double horizontalDistanceSquared = this.position().subtract(landing)
|
||||
.multiply(1.0D, 0.0D, 1.0D).lengthSqr();
|
||||
boolean reachedLanding = this.onGround()
|
||||
@@ -928,8 +928,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
this.performWingGust(level, target);
|
||||
}
|
||||
this.setRoyalFlying(true);
|
||||
this.addGravityAwareImpulse(this, AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
this.addGravityAwareImpulse(this, GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
@@ -943,8 +943,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
double radius = Mth.lerp(progress, 4.0D, STOMP_RADIUS);
|
||||
for (int index = 0; index < 36; index++) {
|
||||
double angle = Mth.TWO_PI * index / 36.0D;
|
||||
Vec3 indicator = this.kingLandingWaypoint.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 indicator = this.kingLandingWaypoint.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
level.sendParticles(ParticleTypes.ELECTRIC_SPARK,
|
||||
this.kingLandingWaypoint.x + Math.cos(angle) * radius,
|
||||
indicator.y,
|
||||
@@ -963,7 +963,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
for (double radius : radii) {
|
||||
double x = target.getX() + Math.cos(angle) * radius;
|
||||
double z = target.getZ() + Math.sin(angle) * radius;
|
||||
double y = AntarchyGravityApi.isGravityInverted(this)
|
||||
double y = GravityApi.isGravityInverted(this)
|
||||
? target.position().y - 0.1D
|
||||
: this.groundYBelow(x, z) + 0.1D;
|
||||
Vec3 candidate = new Vec3(x, y, z);
|
||||
@@ -974,7 +974,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
double fallbackY = AntarchyGravityApi.isGravityInverted(this)
|
||||
double fallbackY = GravityApi.isGravityInverted(this)
|
||||
? target.position().y - 0.1D
|
||||
: this.groundYBelow(target.getX(), target.getZ()) + 0.1D;
|
||||
Vec3 fallback = new Vec3(target.getX(), fallbackY, target.getZ());
|
||||
@@ -986,7 +986,7 @@ public class KingEntity extends RoyalBossEntity {
|
||||
// Last resort: land directly beneath the King if the target ring is obstructed.
|
||||
// This still gives Close Quarters a committed ground sequence instead of silently
|
||||
// remaining airborne over difficult tree geometry.
|
||||
double directY = AntarchyGravityApi.isGravityInverted(this)
|
||||
double directY = GravityApi.isGravityInverted(this)
|
||||
? this.position().y - 0.1D
|
||||
: this.groundYBelow(this.getX(), this.getZ()) + 0.1D;
|
||||
Vec3 direct = new Vec3(this.getX(), directY, this.getZ());
|
||||
@@ -1632,8 +1632,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
continue;
|
||||
}
|
||||
living.hurt(this.damageSources().mobAttack(this), this.scaleRoyalDamage(12.0D));
|
||||
Vec3 lift = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.45D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 lift = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.45D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, this.royalChargeDirection.scale(2.1D).add(lift));
|
||||
living.hasImpulse = true;
|
||||
level.sendParticles(ParticleTypes.END_ROD, living.getX(), living.getY() + living.getBbHeight() * 0.5D,
|
||||
@@ -1821,8 +1821,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
float falloff = (float) Math.max(0.2D, 1.0D - distance / (STOMP_RADIUS + 6.0D));
|
||||
living.hurt(source, base * falloff);
|
||||
Vec3 push = living.position().subtract(this.position()).normalize().scale(2.4D * falloff);
|
||||
Vec3 vertical = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.85D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 vertical = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.85D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, new Vec3(push.x, 0.0D, push.z).add(vertical));
|
||||
living.hasImpulse = true;
|
||||
}
|
||||
@@ -2125,8 +2125,8 @@ public class KingEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
private void sendRoyalJudgmentTelegraph(ServerLevel level, LivingEntity target, int elapsedTicks) {
|
||||
Vec3 targetPoint = target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.35D, 0.0D, AntarchyGravityApi.getGravityDirection(target)));
|
||||
Vec3 targetPoint = target.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.35D, 0.0D, GravityApi.getGravityDirection(target)));
|
||||
double pulse = 0.8D + Math.min(1.0D, elapsedTicks / 20.0D) * 0.5D;
|
||||
for (RoyalHead.Slot slot : RoyalHead.Slot.values()) {
|
||||
RoyalHead head = this.royalHead(slot);
|
||||
|
||||
+37
-37
@@ -6,12 +6,12 @@ import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.entity.ManticoreEntity;
|
||||
import com.craisinlord.antarchy.content.entity.nightmare.NightmareBiteEntity;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityTransition;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationApi;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityTransition;
|
||||
import com.craisinlord.anthology.time.TimeDilationApi;
|
||||
import com.craisinlord.anthology.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -51,8 +51,8 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamSettings;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamTerrainMode;
|
||||
import com.craisinlord.anthology.beam.BeamSettings;
|
||||
import com.craisinlord.anthology.beam.BeamTerrainMode;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalAttackLane;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalEffectController;
|
||||
@@ -406,8 +406,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
protected SoundEvent royalBeamEndSound() { return AntarchySoundEvents.QUEEN_BEAM_END.get(); }
|
||||
|
||||
@Override
|
||||
protected RoyalBeamSettings royalBeamSettings() {
|
||||
return new RoyalBeamSettings(AntarchySettings.queenBeamRange(), AntarchySettings.queenBeamTracking(), 7.5D,
|
||||
protected BeamSettings royalBeamSettings() {
|
||||
return new BeamSettings(AntarchySettings.queenBeamRange(), AntarchySettings.queenBeamTracking(), 7.5D,
|
||||
AntarchySettings.queenBeamDurationTicks(), AntarchySettings.queenBeamTravelTicks(), AntarchySettings.queenBeamCooldownTicks(), 6.0F, 6.0F,
|
||||
(float) AntarchySettings.queenBeamDamage(), 1.0F, 3, 100.0D,
|
||||
(float) AntarchySettings.queenBeamTerrainRadius(), 4.0F, AntarchySettings.queenBeamTerrainCap(),
|
||||
@@ -415,8 +415,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoyalBeamTerrainMode royalBeamTerrainMode() {
|
||||
return RoyalBeamTerrainMode.DESTROY;
|
||||
protected BeamTerrainMode royalBeamTerrainMode() {
|
||||
return BeamTerrainMode.DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -576,7 +576,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
Vec3 away = this.position().subtract(target.position()).multiply(1.0D, 0.0D, 1.0D);
|
||||
double baseAngle = away.lengthSqr() > 1.0E-4D
|
||||
? Math.atan2(away.z, away.x) : this.random.nextDouble() * Mth.TWO_PI;
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double[] radii = {10.0D, 14.0D, 18.0D, 7.0D};
|
||||
for (int angleIndex = 0; angleIndex < 12; angleIndex++) {
|
||||
double angle = baseAngle + angleIndex * Mth.TWO_PI / 12.0D;
|
||||
@@ -614,8 +614,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double progress = this.queenLandingStage == QueenLandingStage.TELEGRAPH
|
||||
? 1.0D - this.queenLandingStageTicks / (double) LANDING_TELEGRAPH_TICKS : 1.0D;
|
||||
double radius = Mth.lerp(progress, 4.0D, 18.0D);
|
||||
Vec3 indicator = this.queenLandingWaypoint.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 indicator = this.queenLandingWaypoint.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
for (int index = 0; index < 40; index++) {
|
||||
double angle = Mth.TWO_PI * index / 40.0D;
|
||||
level.sendParticles(ParticleTypes.REVERSE_PORTAL,
|
||||
@@ -639,8 +639,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
60, 7.0D, 1.0D, 7.0D, 0.12D);
|
||||
}
|
||||
this.setRoyalFlying(true);
|
||||
this.addGravityAwareImpulse(this, AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
this.addGravityAwareImpulse(this, GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.42D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
queen.setPersistenceRequired();
|
||||
queen.setNoGravity(false);
|
||||
ThoraxisUndersideManager.applyUndersideInversion(queen);
|
||||
AntarchyGravityApi.setAirborneGravityDirection(queen, AntarchyGravityDirection.UP, true, new AntarchyGravityTransition(12));
|
||||
GravityApi.setAirborneGravityDirection(queen, GravityDirection.UP, true, new GravityTransition(12));
|
||||
queen.resetFallDistance();
|
||||
return level.addFreshEntity(queen) ? queen : null;
|
||||
}
|
||||
@@ -979,7 +979,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
Vec3 behindTarget = target.position().add(towardTarget.scale(8.0D));
|
||||
Vec3 lateral = new Vec3(-towardTarget.z, 0.0D, towardTarget.x);
|
||||
float tearYaw = (float) Math.toDegrees(Math.atan2(-towardTarget.x, towardTarget.z));
|
||||
double vertical = AntarchyGravityApi.isGravityInverted(this) ? -2.0D : 2.0D;
|
||||
double vertical = GravityApi.isGravityInverted(this) ? -2.0D : 2.0D;
|
||||
for (int i = 0; i < pairs; i++) {
|
||||
double forwardScatter = 3.0D + this.random.nextDouble() * 9.0D;
|
||||
double lateralScatter = (this.random.nextDouble() * 2.0D - 1.0D) * 11.0D;
|
||||
@@ -1157,7 +1157,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
TimeDilationFieldEntity field = TimeDilationApi.createField(level, this.position(),
|
||||
QUEEN_CHRONOSPHERE_RADIUS, QUEEN_CHRONOSPHERE_RATE,
|
||||
QUEEN_CHRONOSPHERE_DURATION, this.getUUID());
|
||||
field.configureQueenChronosphere(this);
|
||||
field.configureOwnerAnchored(this);
|
||||
this.startRoyalRecovery(35);
|
||||
}
|
||||
case "debris_cyclone" -> {
|
||||
@@ -1173,7 +1173,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
}
|
||||
|
||||
private void spawnQueenWingPressure(ServerLevel level) {
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int ring = 1; ring <= 3; ring++) {
|
||||
double radius = ring * 3.2D;
|
||||
int samples = 14 + ring * 4;
|
||||
@@ -1181,9 +1181,9 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double angle = Mth.TWO_PI * sample / samples;
|
||||
double localX = Math.cos(angle) * radius;
|
||||
double localZ = Math.sin(angle) * radius;
|
||||
Vec3 point = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 point = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
localX, this.getBbHeight() * 0.45D, localZ, gravity));
|
||||
Vec3 velocity = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 velocity = GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * 0.2D, 0.025D, Math.sin(angle) * 0.2D, gravity);
|
||||
level.sendParticles(ACCEL_DUST, point.x, point.y, point.z,
|
||||
0, velocity.x, velocity.y, velocity.z, 1.0D);
|
||||
@@ -1258,8 +1258,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double distance = Math.max(1.0D, living.distanceTo(this));
|
||||
living.hurt(source, this.scaleRoyalDamage(12.0D * Math.max(0.25D, 1.0D - distance / 24.0D)));
|
||||
Vec3 push = living.position().subtract(this.position()).normalize().scale(1.3D);
|
||||
Vec3 vertical = AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.65D, 0.0D, AntarchyGravityApi.getGravityDirection(living));
|
||||
Vec3 vertical = GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.65D, 0.0D, GravityApi.getGravityDirection(living));
|
||||
this.addGravityAwareImpulse(living, new Vec3(push.x, 0.0D, push.z).add(vertical));
|
||||
living.hasImpulse = true;
|
||||
}
|
||||
@@ -1281,7 +1281,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
|
||||
private Vec3 selectBlackHoleAnchor(LivingEntity target) {
|
||||
double vertical = 2.0D + this.random.nextDouble() * 2.0D;
|
||||
if (AntarchyGravityApi.isGravityInverted(this)) {
|
||||
if (GravityApi.isGravityInverted(this)) {
|
||||
vertical = -vertical;
|
||||
}
|
||||
return target.position().add(
|
||||
@@ -1399,8 +1399,8 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
int elapsed = GRAVITY_STOMP_TELEGRAPH_TICKS - this.gravityStompTelegraphTicks;
|
||||
if (this.tickCount % 2 == 0) {
|
||||
double radius = Mth.lerp(elapsed / (double) GRAVITY_STOMP_TELEGRAPH_TICKS, 3.0D, 18.0D);
|
||||
Vec3 surfaceCenter = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, AntarchyGravityApi.getGravityDirection(this)));
|
||||
Vec3 surfaceCenter = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D, 0.2D, 0.0D, GravityApi.getGravityDirection(this)));
|
||||
this.spawnQueenTelegraphSpokes(level, surfaceCenter, radius);
|
||||
}
|
||||
this.playQueenTelegraphBeat(level, this.gravityStompTelegraphTicks,
|
||||
@@ -1460,7 +1460,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
this.queenEffectBounds(CRUSHING_GRAVITY_RADIUS),
|
||||
living -> this.canDamageWithRoyalAttack(living)
|
||||
&& this.withinQueenEffectRange(living, CRUSHING_GRAVITY_RADIUS))) {
|
||||
double downSign = AntarchyGravityApi.isGravityInverted(living) ? 1.0D : -1.0D;
|
||||
double downSign = GravityApi.isGravityInverted(living) ? 1.0D : -1.0D;
|
||||
this.spawnCrushingGravityArrow(level, living, downSign, progress);
|
||||
}
|
||||
}
|
||||
@@ -1543,7 +1543,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double orbitRadius = Mth.lerp(Math.min(1.0D, progress * 1.6D), 1.0D, DEBRIS_CYCLONE_ORBIT_RADIUS);
|
||||
double spinSpeed = Mth.lerp(progress, 0.12D, 0.55D);
|
||||
int count = this.debrisCycloneBlocks.size();
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int index = 0; index < count; index++) {
|
||||
FallingBlockEntity block = this.debrisCycloneBlocks.get(index);
|
||||
if (!block.isAlive()) continue;
|
||||
@@ -1551,7 +1551,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
double localX = Math.cos(angle) * orbitRadius;
|
||||
double localZ = Math.sin(angle) * orbitRadius;
|
||||
double localY = this.getBbHeight() * 0.5D + Math.sin(this.tickCount * 0.1D + index) * 0.4D;
|
||||
Vec3 point = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(localX, localY, localZ, gravity));
|
||||
Vec3 point = this.position().add(GravityRotationUtil.vecPlayerToWorld(localX, localY, localZ, gravity));
|
||||
block.setPos(point.x - 0.5D, point.y - 0.5D, point.z - 0.5D);
|
||||
block.setDeltaMovement(Vec3.ZERO);
|
||||
if (this.tickCount % 2 == 0) {
|
||||
@@ -1598,7 +1598,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
this.playRoyalSound(AntarchySoundEvents.QUEEN_ROAR.get(), 0.75F);
|
||||
if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
Vec3 center = this.position();
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
int gathered = 0;
|
||||
for (int attempt = 0; attempt < GRAVITIC_UPHEAVAL_BLOCK_COUNT * 3
|
||||
&& gathered < GRAVITIC_UPHEAVAL_BLOCK_COUNT; attempt++) {
|
||||
@@ -1670,14 +1670,14 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
|
||||
private void spawnBlackHoleFunnel(ServerLevel level, Vec3 center, double fieldRadius, double progress) {
|
||||
double rotation = this.tickCount * 0.35D;
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int tier = 0; tier < 4; tier++) {
|
||||
double tierProgress = tier / 3.0D;
|
||||
double radius = Mth.lerp(progress, fieldRadius * (0.25D + tierProgress * 0.5D), 0.7D);
|
||||
double localY = -1.5D + tierProgress * 4.5D;
|
||||
for (int point = 0; point < 10; point++) {
|
||||
double angle = rotation + tier * 0.65D + Mth.TWO_PI * point / 10.0D;
|
||||
Vec3 particlePos = center.add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 particlePos = center.add(GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * radius, localY, Math.sin(angle) * radius, gravity));
|
||||
level.sendParticles(ParticleTypes.REVERSE_PORTAL,
|
||||
particlePos.x, particlePos.y, particlePos.z,
|
||||
@@ -1742,13 +1742,13 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
private void spawnAccelerationHelix(ServerLevel level, double progress) {
|
||||
double rotation = this.tickCount * Mth.lerp(progress, 0.24D, 0.62D);
|
||||
double radius = Mth.lerp(progress, 2.8D, 0.75D);
|
||||
AntarchyGravityDirection gravity = AntarchyGravityApi.getGravityDirection(this);
|
||||
GravityDirection gravity = GravityApi.getGravityDirection(this);
|
||||
for (int strand = 0; strand < 2; strand++) {
|
||||
for (int segment = 0; segment < 9; segment++) {
|
||||
double heightProgress = segment / 8.0D;
|
||||
double angle = rotation + strand * Math.PI + heightProgress * Mth.TWO_PI * 1.5D;
|
||||
double localY = 0.4D + heightProgress * (this.getBbHeight() + 2.0D);
|
||||
Vec3 particlePos = this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
Vec3 particlePos = this.position().add(GravityRotationUtil.vecPlayerToWorld(
|
||||
Math.cos(angle) * radius, localY, Math.sin(angle) * radius, gravity));
|
||||
level.sendParticles(AntarchyObjects.LUCID_BOLT_IMPACT_SMALL.get(),
|
||||
particlePos.x, particlePos.y, particlePos.z,
|
||||
@@ -1849,7 +1849,7 @@ public class QueenEntity extends RoyalBossEntity {
|
||||
if (entity == this || isFieldImmune(entity) || entity instanceof Player player && player.isCreative()) {
|
||||
continue;
|
||||
}
|
||||
double downSign = AntarchyGravityApi.isGravityInverted(entity) ? 1.0D : -1.0D;
|
||||
double downSign = GravityApi.isGravityInverted(entity) ? 1.0D : -1.0D;
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(0.0D, downSign * CRUSHING_GRAVITY_STRENGTH, 0.0D));
|
||||
entity.hasImpulse = true;
|
||||
if (entity instanceof LivingEntity living && this.tickCount % 8 == 0) {
|
||||
|
||||
+9
-3
@@ -1,8 +1,9 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal;
|
||||
|
||||
import com.craisinlord.anthology.time.TimeDilationAnchor;
|
||||
import com.craisinlord.antarchy.content.AntarchyObjects;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationApi;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.anthology.time.TimeDilationApi;
|
||||
import com.craisinlord.anthology.time.TimeDilationFieldEntity;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.entity.BlockSuction;
|
||||
import java.util.UUID;
|
||||
@@ -36,7 +37,7 @@ import software.bernie.geckolib.animation.PlayState;
|
||||
import software.bernie.geckolib.animation.RawAnimation;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public class RoyalBlackHoleEntity extends Entity implements GeoEntity {
|
||||
public class RoyalBlackHoleEntity extends Entity implements GeoEntity, TimeDilationAnchor {
|
||||
private static final EntityDataAccessor<Float> RADIUS =
|
||||
SynchedEntityData.defineId(RoyalBlackHoleEntity.class, EntityDataSerializers.FLOAT);
|
||||
private static final EntityDataAccessor<Boolean> COLLAPSING =
|
||||
@@ -248,6 +249,11 @@ public class RoyalBlackHoleEntity extends Entity implements GeoEntity {
|
||||
}
|
||||
|
||||
/** Returns the center of the animated black-hole cube in world coordinates. */
|
||||
@Override
|
||||
public Vec3 timeDilationCenter() {
|
||||
return this.effectCenter();
|
||||
}
|
||||
|
||||
public Vec3 effectCenter() {
|
||||
double animationSeconds = Math.min(CORE_RISE_END_SECONDS, this.animationAge / 20.0D);
|
||||
double riseProgress = animationSeconds / CORE_RISE_END_SECONDS;
|
||||
|
||||
+45
-34
@@ -1,17 +1,18 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal;
|
||||
|
||||
import com.craisinlord.anthology.beam.BeamOwner;
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartEntityOwner;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamController;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamSettings;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamTerrainMode;
|
||||
import com.craisinlord.anthology.multipart.MultipartEntityOwner;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.anthology.beam.BeamController;
|
||||
import com.craisinlord.anthology.beam.BeamSettings;
|
||||
import com.craisinlord.anthology.beam.BeamTerrainMode;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalAttackLane;
|
||||
import com.craisinlord.antarchy.content.entity.royal.attack.RoyalAttackScheduler;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -69,7 +70,7 @@ import software.bernie.geckolib.animation.PlayState;
|
||||
import software.bernie.geckolib.animation.RawAnimation;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
public abstract class RoyalBossEntity extends Monster implements GeoEntity, MultipartEntityOwner {
|
||||
public abstract class RoyalBossEntity extends Monster implements GeoEntity, MultipartEntityOwner, BeamOwner {
|
||||
public static final float MODEL_RENDER_SCALE = 2.0F;
|
||||
public static final float GAMEPLAY_WIDTH = 28.0F;
|
||||
public static final float GAMEPLAY_HEIGHT = 15.0F;
|
||||
@@ -165,7 +166,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
private static final RawAnimation DEATH_ANIM = RawAnimation.begin().thenPlayAndHold("death");
|
||||
|
||||
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
|
||||
protected final RoyalBeamController[] beamControllers = new RoyalBeamController[3];
|
||||
protected final BeamController[] beamControllers = new BeamController[3];
|
||||
protected final RoyalAttackScheduler attackScheduler = new RoyalAttackScheduler();
|
||||
private final ServerBossEvent bossEvent;
|
||||
private final RoyalHead[] heads = {
|
||||
@@ -202,7 +203,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
protected RoyalBossEntity(EntityType<? extends RoyalBossEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
for (int i = 0; i < this.beamControllers.length; i++) {
|
||||
this.beamControllers[i] = new RoyalBeamController(this);
|
||||
this.beamControllers[i] = new BeamController(this);
|
||||
}
|
||||
this.xpReward = 500;
|
||||
this.groundMoveControl = new MoveControl(this);
|
||||
@@ -247,9 +248,9 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
|
||||
protected abstract SoundEvent royalBeamEndSound();
|
||||
|
||||
protected abstract RoyalBeamSettings royalBeamSettings();
|
||||
protected abstract BeamSettings royalBeamSettings();
|
||||
|
||||
protected abstract RoyalBeamTerrainMode royalBeamTerrainMode();
|
||||
protected abstract BeamTerrainMode royalBeamTerrainMode();
|
||||
|
||||
protected RoyalBeamElement royalBeamElement(@Nullable RoyalHead head) {
|
||||
return RoyalBeamElement.GENERIC;
|
||||
@@ -266,7 +267,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
protected void tickRoyalBeamEffects(RoyalHead head, Vec3 start, Vec3 end) {
|
||||
}
|
||||
|
||||
protected RoyalBeamTerrainMode royalBeamTerrainMode(@Nullable RoyalHead head) {
|
||||
protected BeamTerrainMode royalBeamTerrainMode(@Nullable RoyalHead head) {
|
||||
return this.royalBeamTerrainMode();
|
||||
}
|
||||
|
||||
@@ -350,18 +351,18 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartLayout antarchy$getMultipartLayout() {
|
||||
public MultipartLayout anthology$getMultipartLayout() {
|
||||
return RoyalBossMultipartLayout.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity[] antarchy$getMultipartParts() {
|
||||
public Entity[] anthology$getMultipartParts() {
|
||||
return this.multipartParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void antarchy$setMultipartParts(@Nullable Entity[] parts) {
|
||||
public void anthology$setMultipartParts(@Nullable Entity[] parts) {
|
||||
this.multipartParts = parts;
|
||||
}
|
||||
|
||||
@@ -526,7 +527,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
if (this.isFlyingBoss()) {
|
||||
this.moveControl = this.isRoyalFlying() ? this.flyingMoveControl : this.groundMoveControl;
|
||||
this.navigation = this.isRoyalFlying() ? this.flyingNavigation : this.groundNavigation;
|
||||
this.setNoGravity(!AntarchyGravityApi.isGravityInverted(this));
|
||||
this.setNoGravity(!GravityApi.isGravityInverted(this));
|
||||
if (!this.isRoyalFlying()) {
|
||||
this.setNoGravity(false);
|
||||
}
|
||||
@@ -642,7 +643,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
for (RoyalHead head : this.heads) {
|
||||
int index = head.slot().ordinal();
|
||||
RoyalBeamController controller = this.beamControllers[index];
|
||||
BeamController controller = this.beamControllers[index];
|
||||
if (controller.isFiring()) {
|
||||
LivingEntity beamTarget = head.target(this.level());
|
||||
if (!head.shooting() || beamTarget == null || !beamTarget.isAlive()
|
||||
@@ -688,7 +689,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
|| !this.targetInBeamLine(head, target)) {
|
||||
continue;
|
||||
}
|
||||
RoyalBeamSettings beamSettings = this.royalBeamSettings();
|
||||
BeamSettings beamSettings = this.royalBeamSettings();
|
||||
int duration = Math.max(1, beamSettings.durationTicks());
|
||||
int cooldown = Math.max(1, Mth.floor(beamSettings.cooldownTicks() * phase.cooldownScale()));
|
||||
int windup = Math.max(0, AntarchySettings.queenBeamWindupTicks());
|
||||
@@ -750,8 +751,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
|
||||
protected final void addGravityAwareImpulse(Entity entity, Vec3 worldImpulse) {
|
||||
AntarchyGravityApi.setWorldVelocity(entity,
|
||||
AntarchyGravityApi.getWorldVelocity(entity).add(worldImpulse));
|
||||
GravityApi.setWorldVelocity(entity,
|
||||
GravityApi.getWorldVelocity(entity).add(worldImpulse));
|
||||
}
|
||||
|
||||
protected final boolean isRoyalPhaseTransitionActive() {
|
||||
@@ -937,7 +938,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
this.aerialCombatAnchor = null;
|
||||
this.aerialCombatAnchorTicks = 0;
|
||||
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double groundBelowTarget = this.groundYBelow(wanted.x, wanted.z);
|
||||
double wantedY = this.landingForCombat
|
||||
? (inverted ? target.getY() + target.getBbHeight() - this.getBbHeight() : groundBelowTarget)
|
||||
@@ -964,7 +965,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
if (!this.isFlyingBoss() || this.managesOwnCombatLocomotion()) {
|
||||
return;
|
||||
}
|
||||
boolean inverted = AntarchyGravityApi.isGravityInverted(this);
|
||||
boolean inverted = GravityApi.isGravityInverted(this);
|
||||
double groundY = this.groundYBelow(this.getX(), this.getZ());
|
||||
if (this.landingForCombat) {
|
||||
if (!target.onGround()) {
|
||||
@@ -1007,7 +1008,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
this.entityData.set(ROYAL_FLYING, flying);
|
||||
this.moveControl = flying ? this.flyingMoveControl : this.groundMoveControl;
|
||||
this.navigation = flying ? this.flyingNavigation : this.groundNavigation;
|
||||
this.setNoGravity(flying && !AntarchyGravityApi.isGravityInverted(this));
|
||||
this.setNoGravity(flying && !GravityApi.isGravityInverted(this));
|
||||
}
|
||||
|
||||
protected double groundYBelow(double x, double z) {
|
||||
@@ -1016,7 +1017,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
}
|
||||
|
||||
private void tickFlyingAltitude() {
|
||||
if (AntarchyGravityApi.isGravityInverted(this)) {
|
||||
if (GravityApi.isGravityInverted(this)) {
|
||||
return;
|
||||
}
|
||||
if (this.onGround()) {
|
||||
@@ -1155,8 +1156,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
forward.x * spec.forwardOffset() + right.x * spec.lateralOffset(),
|
||||
spec.yOffset(),
|
||||
forward.z * spec.forwardOffset() + right.z * spec.lateralOffset());
|
||||
return this.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
AntarchyGravityApi.getGravityDirection(this)));
|
||||
return this.position().add(GravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
GravityApi.getGravityDirection(this)));
|
||||
}
|
||||
|
||||
protected Vec3 beamAnchor(RoyalHead head) {
|
||||
@@ -1166,8 +1167,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
protected Vec3 beamDirection(RoyalHead head) {
|
||||
float yaw = this.getYRot() * Mth.DEG_TO_RAD;
|
||||
Vec3 localDirection = new Vec3(-Math.sin(yaw), 0.0D, Math.cos(yaw));
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localDirection,
|
||||
AntarchyGravityApi.getGravityDirection(this)).normalize();
|
||||
return GravityRotationUtil.vecPlayerToWorld(localDirection,
|
||||
GravityApi.getGravityDirection(this)).normalize();
|
||||
}
|
||||
|
||||
protected boolean targetInBeamLine(RoyalHead head, LivingEntity target) {
|
||||
@@ -1197,8 +1198,8 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
forward.x * BEAM_MUZZLE_FORWARD + right.x * lateral,
|
||||
vertical,
|
||||
forward.z * BEAM_MUZZLE_FORWARD + right.z * lateral);
|
||||
return new Vec3(x, y, z).add(AntarchyGravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
AntarchyGravityApi.getGravityDirection(this)));
|
||||
return new Vec3(x, y, z).add(GravityRotationUtil.vecPlayerToWorld(localOffset,
|
||||
GravityApi.getGravityDirection(this)));
|
||||
}
|
||||
|
||||
protected double royalBeamMinimumRange() {
|
||||
@@ -1220,7 +1221,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
for (RoyalHead head : this.heads) {
|
||||
head.reset();
|
||||
}
|
||||
for (RoyalBeamController controller : this.beamControllers) {
|
||||
for (BeamController controller : this.beamControllers) {
|
||||
controller.stop();
|
||||
}
|
||||
this.setFiringRoyalBeam(false);
|
||||
@@ -1330,7 +1331,7 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
public void setFiringRoyalBeam(boolean firing) {
|
||||
}
|
||||
|
||||
public RoyalBeamController beamController() {
|
||||
public BeamController beamController() {
|
||||
return this.beamControllers[0];
|
||||
}
|
||||
|
||||
@@ -1463,6 +1464,16 @@ public abstract class RoyalBossEntity extends Monster implements GeoEntity, Mult
|
||||
this.applyRoyalDamageModifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float scaleBeamDamage(float damage) {
|
||||
return this.scaleRoyalDamage(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeamDamage(LivingEntity target) {
|
||||
return this.canDamageWithRoyalAttack(target);
|
||||
}
|
||||
|
||||
public float scaleRoyalDamage(double damage) {
|
||||
return (float) (damage * this.royalDamageMultiplier);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartLayout;
|
||||
import com.craisinlord.antarchy.content.entity.multipart.MultipartPartDefinition;
|
||||
import com.craisinlord.anthology.multipart.MultipartLayout;
|
||||
import com.craisinlord.anthology.multipart.MultipartPartDefinition;
|
||||
|
||||
public final class RoyalBossMultipartLayout implements MultipartLayout {
|
||||
public static final RoyalBossMultipartLayout INSTANCE = new RoyalBossMultipartLayout();
|
||||
|
||||
+9
-9
@@ -4,12 +4,12 @@ import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamElement;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamController;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamSettings;
|
||||
import com.craisinlord.antarchy.content.entity.royal.beam.RoyalBeamTerrainMode;
|
||||
import com.craisinlord.anthology.beam.BeamController;
|
||||
import com.craisinlord.anthology.beam.BeamSettings;
|
||||
import com.craisinlord.anthology.beam.BeamTerrainMode;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectEligibility;
|
||||
import com.craisinlord.antarchy.content.effect.RoyalEffectHooks;
|
||||
import com.craisinlord.antarchy.content.time.TimeDilationApi;
|
||||
import com.craisinlord.anthology.time.TimeDilationApi;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -136,7 +136,7 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
|
||||
private int flapSoundTimer;
|
||||
private boolean riderAscendPressed;
|
||||
private boolean riderDescendPressed;
|
||||
private final RoyalBeamController beamController = new RoyalBeamController(this);
|
||||
private final BeamController beamController = new BeamController(this);
|
||||
private int beamWindupTicks;
|
||||
private int beamCooldownTicks;
|
||||
private int beamHead;
|
||||
@@ -540,7 +540,7 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
|
||||
}
|
||||
}
|
||||
if (this.beamController.isFiring()) {
|
||||
this.beamController.tick(this.beamShootFrom(), this.getTarget(), this.beamSettings(), RoyalBeamTerrainMode.NONE, this::setBeamEndPosition);
|
||||
this.beamController.tick(this.beamShootFrom(), this.getTarget(), this.beamSettings(), BeamTerrainMode.NONE, this::setBeamEndPosition);
|
||||
if (!this.beamController.isFiring()) {
|
||||
this.entityData.set(BEAM_ACTIVE, false);
|
||||
this.entityData.set(BEAM_HEAD, -1);
|
||||
@@ -598,9 +598,9 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
|
||||
level.sendParticles(ParticleTypes.END_ROD, center.x, center.y + 0.5D, center.z, 28, 1.2D, 0.6D, 1.2D, 0.03D);
|
||||
}
|
||||
|
||||
private RoyalBeamSettings beamSettings() {
|
||||
private BeamSettings beamSettings() {
|
||||
float damage = this instanceof PrincessEntity ? 10.0F : 12.0F;
|
||||
return new RoyalBeamSettings(28.0D, 0.08D, 4.0D, BEAM_DURATION_TICKS, 6, BEAM_COOLDOWN_TICKS,
|
||||
return new BeamSettings(28.0D, 0.08D, 4.0D, BEAM_DURATION_TICKS, 6, BEAM_COOLDOWN_TICKS,
|
||||
0.35F, 0.45F, damage, 0.45F, 3, 0.0D, 0.0F, 0.0F, 0, 0.0F, 0.0F, 0.0F, false, true);
|
||||
}
|
||||
|
||||
@@ -622,7 +622,7 @@ public abstract class RoyalMountEntity extends TamableAnimal implements GeoEntit
|
||||
return this.entityData.get(HAS_BEAM_END) ? new Vec3(this.entityData.get(BEAM_END_X), this.entityData.get(BEAM_END_Y), this.entityData.get(BEAM_END_Z)) : null;
|
||||
}
|
||||
public RoyalBeamElement getBeamElement() { return RoyalBeamElement.GENERIC; }
|
||||
public RoyalBeamController beamController() { return this.beamController; }
|
||||
public BeamController beamController() { return this.beamController; }
|
||||
private void setBeamEndPosition(@Nullable Vec3 position) {
|
||||
this.entityData.set(HAS_BEAM_END, position != null);
|
||||
if (position != null) {
|
||||
|
||||
-385
@@ -1,385 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal.beam;
|
||||
|
||||
import com.craisinlord.antarchy.content.entity.royal.RoyalBossEntity;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySelector;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class RoyalBeamController {
|
||||
private static final int INITIAL_TRACKING_DELAY_TICKS = 8;
|
||||
private final LivingEntity owner;
|
||||
private Vec3 serverTarget;
|
||||
private Vec3 beamEndPosition;
|
||||
private int beamTicks;
|
||||
private int beamAgeTicks;
|
||||
private int trackingDelayTicks;
|
||||
private int terrainMutationsThisTick;
|
||||
private final Set<Integer> damagedThisTick = new HashSet<>();
|
||||
private static final int ICE_MUTATIONS_PER_TICK = 3;
|
||||
private static final float ICE_IMPACT_RADIUS = 2.0F;
|
||||
|
||||
public RoyalBeamController(LivingEntity owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public RoyalBeamController(Mob owner) {
|
||||
this((LivingEntity) owner);
|
||||
}
|
||||
|
||||
public boolean isFiring() {
|
||||
return this.beamTicks > 0;
|
||||
}
|
||||
|
||||
public int beamTicks() {
|
||||
return this.beamTicks;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Vec3 beamEndPosition() {
|
||||
return this.beamEndPosition;
|
||||
}
|
||||
|
||||
public void start(Vec3 shootFrom, Vec3 target, int durationTicks) {
|
||||
this.serverTarget = target;
|
||||
this.beamEndPosition = target;
|
||||
this.beamTicks = Math.max(1, durationTicks);
|
||||
this.beamAgeTicks = 0;
|
||||
this.trackingDelayTicks = INITIAL_TRACKING_DELAY_TICKS;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.serverTarget = null;
|
||||
this.beamEndPosition = null;
|
||||
this.beamTicks = 0;
|
||||
this.beamAgeTicks = 0;
|
||||
}
|
||||
|
||||
public void tick(
|
||||
Vec3 shootFrom,
|
||||
@Nullable LivingEntity target,
|
||||
RoyalBeamSettings settings,
|
||||
RoyalBeamTerrainMode terrainMode,
|
||||
Consumer<@Nullable Vec3> syncedEndPosition
|
||||
) {
|
||||
this.tick(shootFrom, owner.getLookAngle(), target, settings, terrainMode, syncedEndPosition);
|
||||
}
|
||||
|
||||
public void tick(
|
||||
Vec3 shootFrom,
|
||||
Vec3 shootDirection,
|
||||
@Nullable LivingEntity target,
|
||||
RoyalBeamSettings settings,
|
||||
RoyalBeamTerrainMode terrainMode,
|
||||
Consumer<@Nullable Vec3> syncedEndPosition
|
||||
) {
|
||||
this.tick(shootFrom, shootDirection, target, settings, terrainMode, syncedEndPosition, false);
|
||||
}
|
||||
|
||||
public void tick(
|
||||
Vec3 shootFrom,
|
||||
Vec3 shootDirection,
|
||||
@Nullable LivingEntity target,
|
||||
RoyalBeamSettings settings,
|
||||
RoyalBeamTerrainMode terrainMode,
|
||||
Consumer<@Nullable Vec3> syncedEndPosition,
|
||||
boolean useTrackedTargetAim
|
||||
) {
|
||||
if (this.beamTicks <= 0) {
|
||||
syncedEndPosition.accept(null);
|
||||
return;
|
||||
}
|
||||
|
||||
this.beamTicks--;
|
||||
this.beamAgeTicks++;
|
||||
this.terrainMutationsThisTick = 0;
|
||||
if (this.trackingDelayTicks > 0) {
|
||||
this.trackingDelayTicks--;
|
||||
} else if (target != null && target.isAlive()) {
|
||||
Vec3 targetEye = target.getEyePosition();
|
||||
this.serverTarget = this.serverTarget == null
|
||||
? targetEye
|
||||
: this.serverTarget.add(targetEye.subtract(this.serverTarget).scale(settings.targetTracking()));
|
||||
}
|
||||
if (this.serverTarget == null) {
|
||||
this.stop();
|
||||
syncedEndPosition.accept(null);
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 trackedDirection = this.serverTarget.subtract(shootFrom);
|
||||
Vec3 direction = useTrackedTargetAim && trackedDirection.lengthSqr() >= 1.0E-7D
|
||||
? trackedDirection.normalize()
|
||||
: shootDirection.lengthSqr() < 1.0E-7D
|
||||
? this.owner.getLookAngle().normalize()
|
||||
: shootDirection.normalize();
|
||||
double committedDistance = Math.min(settings.range(), Math.max(settings.pathStep(),
|
||||
this.serverTarget.subtract(shootFrom).dot(direction)));
|
||||
double travelProgress = Mth.clamp(this.beamAgeTicks / (double) settings.travelTicks(), 0.0D, 1.0D);
|
||||
double currentRange = Math.max(settings.pathStep(), committedDistance * travelProgress);
|
||||
Vec3 clipEnd = shootFrom.add(direction.scale(currentRange));
|
||||
HitResult hit = this.owner.level().clip(new ClipContext(
|
||||
shootFrom,
|
||||
clipEnd,
|
||||
ClipContext.Block.COLLIDER,
|
||||
ClipContext.Fluid.NONE,
|
||||
this.owner
|
||||
));
|
||||
this.beamEndPosition = hit.getLocation();
|
||||
syncedEndPosition.accept(this.beamEndPosition);
|
||||
|
||||
if (!this.owner.level().isClientSide && this.beamEndPosition != null) {
|
||||
boolean impactedBlock = hit.getType() == HitResult.Type.BLOCK;
|
||||
marchDamageAndTerrain(shootFrom, this.beamEndPosition, settings, terrainMode, impactedBlock);
|
||||
}
|
||||
|
||||
if (this.beamTicks <= 0) {
|
||||
this.stop();
|
||||
syncedEndPosition.accept(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void marchDamageAndTerrain(
|
||||
Vec3 shootFrom,
|
||||
Vec3 beamEnd,
|
||||
RoyalBeamSettings settings,
|
||||
RoyalBeamTerrainMode terrainMode,
|
||||
boolean impactedBlock
|
||||
) {
|
||||
Vec3 direction = beamEnd.subtract(shootFrom).normalize();
|
||||
double distance = shootFrom.distanceTo(beamEnd);
|
||||
DamageSource damageSource = this.owner instanceof Player player
|
||||
? player.damageSources().playerAttack(player)
|
||||
: this.owner.damageSources().mobAttack(this.owner);
|
||||
this.damagedThisTick.clear();
|
||||
boolean pathMutates = terrainMode == RoyalBeamTerrainMode.DESTROY;
|
||||
for (double walked = settings.pathStep(); walked < Math.min(distance, settings.range()); walked += settings.pathStep()) {
|
||||
Vec3 sample = shootFrom.add(direction.scale(walked));
|
||||
hurtEntitiesAround(sample, settings.pathDamageRadius(), this.scaledDamage(settings.damage()), settings.knockback(), damageSource, settings.requireLineOfSightForDamage(), this.damagedThisTick);
|
||||
if (pathMutates && shouldMutateTerrain(settings, walked)) {
|
||||
mutateTerrainAround(sample, settings.pathTerrainRadius(), settings, terrainMode);
|
||||
}
|
||||
}
|
||||
|
||||
hurtEntitiesAround(beamEnd, settings.impactDamageRadius(), this.scaledDamage(settings.damage()), settings.knockback(), damageSource, settings.requireLineOfSightForDamage(), this.damagedThisTick);
|
||||
|
||||
if (!shouldMutateTerrain(settings, distance)) {
|
||||
return;
|
||||
}
|
||||
if (terrainMode == RoyalBeamTerrainMode.BUILD_ICE) {
|
||||
if (impactedBlock) {
|
||||
mutateTerrainAround(beamEnd, ICE_IMPACT_RADIUS, settings, terrainMode);
|
||||
}
|
||||
} else {
|
||||
mutateTerrainAround(beamEnd, settings.impactTerrainRadius(), settings, terrainMode);
|
||||
}
|
||||
}
|
||||
|
||||
private float scaledDamage(float damage) {
|
||||
return this.owner instanceof RoyalBossEntity royalBoss ? royalBoss.scaleRoyalDamage(damage) : damage;
|
||||
}
|
||||
|
||||
private boolean shouldMutateTerrain(RoyalBeamSettings settings, double distanceFromOwner) {
|
||||
return settings.terrainEnabled()
|
||||
&& settings.maxTerrainMutationsPerTick() > 0
|
||||
&& this.beamTicks % settings.terrainIntervalTicks() == 0
|
||||
&& distanceFromOwner <= settings.maxTerrainDistance()
|
||||
&& this.owner.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
|
||||
}
|
||||
|
||||
private boolean hurtEntitiesAround(
|
||||
Vec3 center,
|
||||
float radius,
|
||||
float damageAmount,
|
||||
float knockbackAmount,
|
||||
DamageSource damageSource,
|
||||
boolean requireLineOfSight,
|
||||
Set<Integer> damagedThisTick
|
||||
) {
|
||||
if (radius <= 0.0F || damageAmount <= 0.0F) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AABB aabb = new AABB(center.subtract(radius, radius, radius), center.add(radius, radius, radius));
|
||||
List<LivingEntity> entities = this.owner.level().getEntitiesOfClass(
|
||||
LivingEntity.class,
|
||||
aabb,
|
||||
EntitySelector.NO_CREATIVE_OR_SPECTATOR
|
||||
);
|
||||
boolean hurtAny = false;
|
||||
for (LivingEntity living : entities) {
|
||||
if (living.is(this.owner)
|
||||
|| this.owner.isAlliedTo(living)
|
||||
|| !(this.owner instanceof Player) && living.getType() == this.owner.getType()
|
||||
|| this.owner instanceof RoyalBossEntity royalBoss && !royalBoss.canDamageWithRoyalAttack(living)
|
||||
|| living.distanceToSqr(center) > radius * radius
|
||||
|| damagedThisTick.contains(living.getId())
|
||||
|| requireLineOfSight && !canEntityBeHurtFrom(center, living)) {
|
||||
continue;
|
||||
}
|
||||
if (living.hurt(damageSource, damageAmount)) {
|
||||
damagedThisTick.add(living.getId());
|
||||
hurtAny = true;
|
||||
knockbackTarget(living, knockbackAmount);
|
||||
}
|
||||
}
|
||||
return hurtAny;
|
||||
}
|
||||
|
||||
private boolean canEntityBeHurtFrom(Vec3 center, LivingEntity living) {
|
||||
Vec3 targetCenter = living.position().add(0.0D, living.getBbHeight() * 0.5D, 0.0D);
|
||||
return this.owner.level().clip(new ClipContext(
|
||||
center,
|
||||
targetCenter,
|
||||
ClipContext.Block.COLLIDER,
|
||||
ClipContext.Fluid.NONE,
|
||||
this.owner
|
||||
)).getType() == HitResult.Type.MISS;
|
||||
}
|
||||
|
||||
private void knockbackTarget(Entity target, double strength) {
|
||||
if (strength <= 0.0D) {
|
||||
return;
|
||||
}
|
||||
|
||||
double resistance = target instanceof LivingEntity living
|
||||
? living.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)
|
||||
: 0.0D;
|
||||
double appliedStrength = strength * Math.max(0.0D, 1.0D - resistance);
|
||||
if (appliedStrength <= 0.0D) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 push = target.position().subtract(this.owner.position()).multiply(1.0D, 0.0D, 1.0D).normalize().scale(appliedStrength);
|
||||
Vec3 movement = target.getDeltaMovement();
|
||||
target.setDeltaMovement(
|
||||
movement.x * 0.5D + push.x,
|
||||
Math.min(0.4D, movement.y * 0.5D + appliedStrength),
|
||||
movement.z * 0.5D + push.z
|
||||
);
|
||||
target.hasImpulse = true;
|
||||
}
|
||||
|
||||
private void mutateTerrainAround(
|
||||
Vec3 center,
|
||||
float radius,
|
||||
RoyalBeamSettings settings,
|
||||
RoyalBeamTerrainMode terrainMode
|
||||
) {
|
||||
if (terrainMode == RoyalBeamTerrainMode.NONE || radius <= 0.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
Level level = this.owner.level();
|
||||
int minX = Mth.floor(center.x - radius);
|
||||
int minY = Mth.floor(center.y - radius);
|
||||
int minZ = Mth.floor(center.z - radius);
|
||||
int maxX = Mth.floor(center.x + radius);
|
||||
int maxY = Mth.floor(center.y + radius);
|
||||
int maxZ = Mth.floor(center.z + radius);
|
||||
float radiusSqr = radius * radius;
|
||||
|
||||
int cap = terrainMode == RoyalBeamTerrainMode.BUILD_ICE
|
||||
? Math.min(ICE_MUTATIONS_PER_TICK, settings.maxTerrainMutationsPerTick())
|
||||
: settings.maxTerrainMutationsPerTick();
|
||||
for (BlockPos cursor : BlockPos.betweenClosed(minX, minY, minZ, maxX, maxY, maxZ)) {
|
||||
if (this.terrainMutationsThisTick >= cap) {
|
||||
return;
|
||||
}
|
||||
BlockPos pos = cursor.immutable();
|
||||
if (pos.distToCenterSqr(center.x, center.y, center.z) > radiusSqr
|
||||
|| this.owner.getRandom().nextFloat() > settings.terrainMutationChance()
|
||||
|| pos.getY() < level.getMinBuildHeight()
|
||||
|| pos.getY() >= level.getMaxBuildHeight()
|
||||
|| !level.getWorldBorder().isWithinBounds(pos)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockState existing = level.getBlockState(pos);
|
||||
if (terrainMode == RoyalBeamTerrainMode.DESTROY) {
|
||||
destroyBeamBlock(level, pos, existing, settings);
|
||||
} else if (terrainMode == RoyalBeamTerrainMode.BUILD_ICE) {
|
||||
buildIceBlock(level, pos, existing, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyBeamBlock(Level level, BlockPos pos, BlockState existing, RoyalBeamSettings settings) {
|
||||
if (existing.isAir()
|
||||
|| level.getBlockEntity(pos) != null
|
||||
|| existing.getDestroySpeed(level, pos) < 0.0F
|
||||
|| existing.getBlock().getExplosionResistance() > settings.maxTerrainResistance()
|
||||
|| existing.getCollisionShape(level, pos).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.owner.getRandom().nextFloat() <= settings.terrainDropChance()) {
|
||||
level.destroyBlock(pos, true, this.owner);
|
||||
} else {
|
||||
level.levelEvent(2001, pos, Block.getId(existing));
|
||||
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
this.terrainMutationsThisTick++;
|
||||
}
|
||||
|
||||
private void buildIceBlock(Level level, BlockPos pos, BlockState existing, RoyalBeamSettings settings) {
|
||||
boolean replaceable = existing.isAir()
|
||||
|| existing.canBeReplaced()
|
||||
|| !existing.getFluidState().isEmpty();
|
||||
if (!replaceable || level.getBlockEntity(pos) != null || existing.is(BlockTags.ICE)) {
|
||||
return;
|
||||
}
|
||||
if (!touchesFreezableSurface(level, pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
level.levelEvent(2001, pos, Block.getId(existing));
|
||||
level.setBlock(pos, randomIceBlock().defaultBlockState(), Block.UPDATE_ALL);
|
||||
this.terrainMutationsThisTick++;
|
||||
}
|
||||
|
||||
private static boolean touchesFreezableSurface(Level level, BlockPos pos) {
|
||||
for (Direction direction : Direction.values()) {
|
||||
BlockPos neighbor = pos.relative(direction);
|
||||
BlockState state = level.getBlockState(neighbor);
|
||||
if (state.is(BlockTags.ICE) || state.is(Blocks.SNOW_BLOCK)) {
|
||||
continue;
|
||||
}
|
||||
if (state.isFaceSturdy(level, neighbor, direction.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Block randomIceBlock() {
|
||||
return switch (this.owner.getRandom().nextInt(5)) {
|
||||
case 0 -> Blocks.BLUE_ICE;
|
||||
case 1 -> Blocks.PACKED_ICE;
|
||||
case 2 -> Blocks.FROSTED_ICE;
|
||||
case 3 -> Blocks.SNOW_BLOCK;
|
||||
default -> Blocks.ICE;
|
||||
};
|
||||
}
|
||||
}
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal.beam;
|
||||
|
||||
public record RoyalBeamSettings(
|
||||
double range,
|
||||
double targetTracking,
|
||||
double pathStep,
|
||||
int durationTicks,
|
||||
int travelTicks,
|
||||
int cooldownTicks,
|
||||
float pathDamageRadius,
|
||||
float impactDamageRadius,
|
||||
float damage,
|
||||
float knockback,
|
||||
int terrainIntervalTicks,
|
||||
double maxTerrainDistance,
|
||||
float pathTerrainRadius,
|
||||
float impactTerrainRadius,
|
||||
int maxTerrainMutationsPerTick,
|
||||
float terrainMutationChance,
|
||||
float terrainDropChance,
|
||||
float maxTerrainResistance,
|
||||
boolean terrainEnabled,
|
||||
boolean requireLineOfSightForDamage
|
||||
) {
|
||||
public static RoyalBeamSettings gauntletPower() {
|
||||
return new RoyalBeamSettings(64.0D, 0.0D, 2.0D, 18, 4, 50, 0.9F, 1.8F,
|
||||
9.0F, 0.8F, 1, 64.0D, 0.8F, 1.8F, 6, 1.0F, 1.0F, 50.0F, true, false);
|
||||
}
|
||||
|
||||
public static RoyalBeamSettings gauntletInfinity() {
|
||||
return new RoyalBeamSettings(64.0D, 0.0D, 1.5D, 24, 4, 1200, 1.25F, 2.5F,
|
||||
28.0F, 1.8F, 1, 64.0D, 1.0F, 2.0F, 0, 0.0F, 0.0F, 0.0F, false, false);
|
||||
}
|
||||
|
||||
public static RoyalBeamSettings tremorzillaLike(float damage, boolean terrainEnabled) {
|
||||
return new RoyalBeamSettings(
|
||||
100.0D,
|
||||
0.1D,
|
||||
7.5D,
|
||||
30,
|
||||
12,
|
||||
90,
|
||||
6.0F,
|
||||
6.0F,
|
||||
damage,
|
||||
1.0F,
|
||||
3,
|
||||
100.0D,
|
||||
5.0F,
|
||||
4.0F,
|
||||
192,
|
||||
1.0F,
|
||||
0.08F,
|
||||
15.0F,
|
||||
terrainEnabled,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public RoyalBeamSettings {
|
||||
range = Math.max(1.0D, range);
|
||||
targetTracking = Math.clamp(targetTracking, 0.0D, 1.0D);
|
||||
pathStep = Math.max(1.0D, pathStep);
|
||||
durationTicks = Math.max(1, durationTicks);
|
||||
travelTicks = Math.max(1, travelTicks);
|
||||
cooldownTicks = Math.max(1, cooldownTicks);
|
||||
pathDamageRadius = Math.max(0.0F, pathDamageRadius);
|
||||
impactDamageRadius = Math.max(0.0F, impactDamageRadius);
|
||||
damage = Math.max(0.0F, damage);
|
||||
knockback = Math.max(0.0F, knockback);
|
||||
terrainIntervalTicks = Math.max(1, terrainIntervalTicks);
|
||||
maxTerrainDistance = Math.max(0.0D, maxTerrainDistance);
|
||||
pathTerrainRadius = Math.max(0.0F, pathTerrainRadius);
|
||||
impactTerrainRadius = Math.max(0.0F, impactTerrainRadius);
|
||||
maxTerrainMutationsPerTick = Math.max(0, maxTerrainMutationsPerTick);
|
||||
terrainMutationChance = Math.clamp(terrainMutationChance, 0.0F, 1.0F);
|
||||
terrainDropChance = Math.clamp(terrainDropChance, 0.0F, 1.0F);
|
||||
maxTerrainResistance = Math.max(0.0F, maxTerrainResistance);
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.entity.royal.beam;
|
||||
|
||||
public enum RoyalBeamTerrainMode {
|
||||
NONE,
|
||||
DESTROY,
|
||||
BUILD_ICE
|
||||
}
|
||||
+8
-8
@@ -2,9 +2,9 @@ package com.craisinlord.antarchy.content.entity.stratoshark;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchySoundEvents;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityDirection;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityDirection;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -607,20 +607,20 @@ public class StratosharkEntity extends Monster implements GeoEntity {
|
||||
}
|
||||
}
|
||||
|
||||
private AntarchyGravityDirection gravityDirection() {
|
||||
return AntarchyGravityApi.getGravityDirection(this);
|
||||
private GravityDirection gravityDirection() {
|
||||
return GravityApi.getGravityDirection(this);
|
||||
}
|
||||
|
||||
private Vec3 toLocal(Vec3 worldVector) {
|
||||
return AntarchyGravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecWorldToPlayer(worldVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(Vec3 localVector) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(localVector, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toWorld(double x, double y, double z) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
return GravityRotationUtil.vecPlayerToWorld(x, y, z, this.gravityDirection());
|
||||
}
|
||||
|
||||
private Vec3 toLocalPlane(Vec3 worldVector) {
|
||||
|
||||
+4
-4
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.content.entity.vortex;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.worldgen.thoraxis.ThoraxisUndersideManager;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
@@ -203,7 +203,7 @@ public class VortexEntity extends Monster implements GeoEntity {
|
||||
private void tickCombatMovement(LivingEntity target) {
|
||||
this.faceTowards(target.position().add(0.0D, target.getBbHeight() * 0.5D, 0.0D), 12.0F, 8.0F);
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(this).getOpposite().getNormal());
|
||||
Vec3 hoverPosition = target.position().add(gravityUp.scale(2.5D));
|
||||
this.getMoveControl().setWantedPosition(hoverPosition.x, hoverPosition.y, hoverPosition.z, 0.38D);
|
||||
|
||||
@@ -256,7 +256,7 @@ public class VortexEntity extends Monster implements GeoEntity {
|
||||
double distance = direction.length();
|
||||
Vec3 drift = distance > 1.0E-6D ? direction.scale(0.24D / distance) : this.getViewVector(1.0F).scale(0.24D);
|
||||
WindVortexEntity vortex = WindVortexEntity.create(serverLevel, windVortexTypeSupplier.get(), origin, Vec3.ZERO, this, true);
|
||||
vortex.setAxis(AntarchyGravityRotationUtil.getGravityDownDirection(this).getOpposite());
|
||||
vortex.setAxis(GravityRotationUtil.getGravityDownDirection(this).getOpposite());
|
||||
vortex.setTravel(drift);
|
||||
vortex.setTravelDuration(Mth.clamp((int) Math.ceil(distance / drift.length()), 8, 36));
|
||||
vortex.setHoming(false);
|
||||
|
||||
+7
-7
@@ -2,8 +2,8 @@ package com.craisinlord.antarchy.content.entity.vortex;
|
||||
|
||||
import com.craisinlord.antarchy.config.AntarchySettings;
|
||||
import com.craisinlord.antarchy.content.AntarchyTags;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityApi;
|
||||
import com.craisinlord.antarchy.content.gravity.AntarchyGravityRotationUtil;
|
||||
import com.craisinlord.anthology.gravity.GravityApi;
|
||||
import com.craisinlord.anthology.gravity.GravityRotationUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -508,7 +508,7 @@ public class WindVortexEntity extends Entity {
|
||||
.add(tangent.scale(spin))
|
||||
.add(basis.axis.scale(axialSpeed))
|
||||
.scale(ENTITY_FORCE_SPEED_SCALE);
|
||||
Vec3 current = AntarchyGravityApi.getWorldVelocity(entity);
|
||||
Vec3 current = GravityApi.getWorldVelocity(entity);
|
||||
Vec3 updatedMovement = current.lerp(wanted, 0.72D);
|
||||
if (this.travelling) {
|
||||
updatedMovement = updatedMovement.add(this.travelVelocity.scale(0.8D * ENTITY_FORCE_SPEED_SCALE));
|
||||
@@ -516,12 +516,12 @@ public class WindVortexEntity extends Entity {
|
||||
if (mode == VortexMode.UPWARD && entity.onGround()) {
|
||||
double minRise = (entity instanceof Player ? 0.38D : 0.3D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
double minimumAxialSpeed = Math.max(updatedMovement.dot(gravityUp), minRise);
|
||||
updatedMovement = updatedMovement.add(gravityUp.scale(minimumAxialSpeed - updatedMovement.dot(gravityUp)));
|
||||
entity.setOnGround(false);
|
||||
}
|
||||
AntarchyGravityApi.setWorldVelocity(entity, updatedMovement);
|
||||
GravityApi.setWorldVelocity(entity, updatedMovement);
|
||||
if (entity instanceof Player) {
|
||||
entity.setOnGround(false);
|
||||
}
|
||||
@@ -572,7 +572,7 @@ public class WindVortexEntity extends Entity {
|
||||
double arc = Mth.clamp(distance * 0.06D, 0.25D, 1.1D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
double power = this.launchStrength * Mth.clamp(distance / 6.0D, 0.6D, 2.0D) * ENTITY_FORCE_SPEED_SCALE;
|
||||
Vec3 gravityUp = Vec3.atLowerCornerOf(
|
||||
AntarchyGravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
GravityRotationUtil.getGravityDownDirection(entity).getOpposite().getNormal());
|
||||
this.setWorldVelocity(entity, direction.scale(power).add(gravityUp.scale(arc)));
|
||||
entity.fallDistance = 0.0F;
|
||||
entity.hasImpulse = true;
|
||||
@@ -592,7 +592,7 @@ public class WindVortexEntity extends Entity {
|
||||
}
|
||||
|
||||
private void setWorldVelocity(Entity entity, Vec3 velocity) {
|
||||
AntarchyGravityApi.setWorldVelocity(entity, velocity);
|
||||
GravityApi.setWorldVelocity(entity, velocity);
|
||||
}
|
||||
|
||||
private DamageSource damageSource() {
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
public interface AntarchyGravityAccess {
|
||||
AntarchyGravityDirection antarchy$getGravityDirection();
|
||||
|
||||
AntarchyGravityDirection antarchy$getPrevGravityDirection();
|
||||
|
||||
boolean antarchy$isGravityForced();
|
||||
|
||||
int antarchy$getGravityTransitionDuration();
|
||||
|
||||
int antarchy$getGravityTransitionRemaining();
|
||||
|
||||
void antarchy$setGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition);
|
||||
|
||||
void antarchy$setAirborneGravityState(AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition);
|
||||
|
||||
void antarchy$applySyncedGravityState(
|
||||
AntarchyGravityDirection direction,
|
||||
AntarchyGravityDirection previousDirection,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
);
|
||||
}
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public final class AntarchyGravityApi {
|
||||
public interface GravitySyncDispatcher {
|
||||
void onGravityStateChanged(Entity entity);
|
||||
}
|
||||
|
||||
private static GravitySyncDispatcher syncDispatcher = entity -> {
|
||||
};
|
||||
|
||||
private AntarchyGravityApi() {
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection getGravityDirection(Entity entity) {
|
||||
return access(entity).antarchy$getGravityDirection();
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection getPrevGravityDirection(Entity entity) {
|
||||
return access(entity).antarchy$getPrevGravityDirection();
|
||||
}
|
||||
|
||||
public static boolean isGravityForced(Entity entity) {
|
||||
return access(entity).antarchy$isGravityForced();
|
||||
}
|
||||
|
||||
public static boolean isGravityInverted(Entity entity) {
|
||||
return getGravityDirection(entity).isInverted();
|
||||
}
|
||||
|
||||
public static int getTransitionDuration(Entity entity) {
|
||||
return access(entity).antarchy$getGravityTransitionDuration();
|
||||
}
|
||||
|
||||
public static int getTransitionRemaining(Entity entity) {
|
||||
return access(entity).antarchy$getGravityTransitionRemaining();
|
||||
}
|
||||
|
||||
public static float getGravityFlipProgress(Entity entity, float partialTick) {
|
||||
AntarchyGravityAccess access = access(entity);
|
||||
AntarchyGravityDirection current = access.antarchy$getGravityDirection();
|
||||
AntarchyGravityDirection previous = access.antarchy$getPrevGravityDirection();
|
||||
int duration = access.antarchy$getGravityTransitionDuration();
|
||||
int remaining = access.antarchy$getGravityTransitionRemaining();
|
||||
if (duration <= 0 || current == previous) {
|
||||
return current.isInverted() ? 1.0F : 0.0F;
|
||||
}
|
||||
|
||||
float elapsed = duration - remaining + partialTick;
|
||||
float fraction = Math.max(0.0F, Math.min(1.0F, elapsed / duration));
|
||||
return previous.isInverted() ? 1.0F - fraction : fraction;
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction) {
|
||||
setGravityDirection(entity, direction, false, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, AntarchyGravityTransition transition) {
|
||||
setGravityDirection(entity, direction, false, transition);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced) {
|
||||
setGravityDirection(entity, direction, forced, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setGravityState(direction, forced, transition);
|
||||
}
|
||||
|
||||
public static void setForcedGravityDirection(Entity entity, AntarchyGravityDirection direction) {
|
||||
setForcedGravityDirection(entity, direction, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void setForcedGravityDirection(Entity entity, AntarchyGravityDirection direction, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setGravityState(direction, true, transition);
|
||||
}
|
||||
|
||||
public static void setAirborneGravityDirection(Entity entity, AntarchyGravityDirection direction, boolean forced, AntarchyGravityTransition transition) {
|
||||
access(entity).antarchy$setAirborneGravityState(direction, forced, transition);
|
||||
}
|
||||
|
||||
public static void clearForcedGravity(Entity entity) {
|
||||
access(entity).antarchy$setGravityState(AntarchyGravityDirection.DOWN, false, AntarchyGravityTransition.INSTANT);
|
||||
}
|
||||
|
||||
public static void applySyncedState(
|
||||
Entity entity,
|
||||
AntarchyGravityDirection direction,
|
||||
AntarchyGravityDirection previousDirection,
|
||||
boolean forced,
|
||||
int transitionDuration,
|
||||
int transitionRemaining
|
||||
) {
|
||||
access(entity).antarchy$applySyncedGravityState(direction, previousDirection, forced, transitionDuration, transitionRemaining);
|
||||
}
|
||||
|
||||
public static void setSyncDispatcher(GravitySyncDispatcher dispatcher) {
|
||||
syncDispatcher = dispatcher;
|
||||
}
|
||||
|
||||
public static void notifyGravityStateChanged(Entity entity) {
|
||||
syncDispatcher.onGravityStateChanged(entity);
|
||||
}
|
||||
|
||||
public static Vec3 getWorldVelocity(Entity entity) {
|
||||
return AntarchyGravityRotationUtil.vecPlayerToWorld(entity.getDeltaMovement(), getGravityDirection(entity));
|
||||
}
|
||||
|
||||
public static void setWorldVelocity(Entity entity, Vec3 worldVelocity) {
|
||||
entity.setDeltaMovement(AntarchyGravityRotationUtil.vecWorldToPlayer(worldVelocity, getGravityDirection(entity)));
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity) {
|
||||
return AntarchyGravityRotationUtil.getEyeOffset(entity, entity.getEyeHeight());
|
||||
}
|
||||
|
||||
public static double eyeX(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().x : entity.getX();
|
||||
}
|
||||
|
||||
public static double eyeY(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().y : entity.getY();
|
||||
}
|
||||
|
||||
public static double eyeZ(Entity entity) {
|
||||
return isGravityInverted(entity) ? entity.getEyePosition().z : entity.getZ();
|
||||
}
|
||||
|
||||
public static Vec3 deltaMovement(net.minecraft.world.entity.LivingEntity target) {
|
||||
return isGravityInverted(target) ? getWorldVelocity(target) : target.getDeltaMovement();
|
||||
}
|
||||
|
||||
public static double projectileSpawnX(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).x;
|
||||
}
|
||||
|
||||
public static double projectileSpawnY(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).y;
|
||||
}
|
||||
|
||||
public static double projectileSpawnZ(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
return projectileSpawnVec(shooter).z;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetX(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getX();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).x;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetY(net.minecraft.world.entity.LivingEntity target, double heightScale) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getY(heightScale);
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).y;
|
||||
}
|
||||
|
||||
public static double rangedBodyTargetZ(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getZ();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getBbHeight() * 0.3333333333333333D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).z;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetX(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getX();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).x;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetY(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getEyeY();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).y + 1.100000023841858D;
|
||||
}
|
||||
|
||||
public static double rangedEyeTargetZ(net.minecraft.world.entity.LivingEntity target) {
|
||||
if (!isGravityInverted(target)) {
|
||||
return target.getZ();
|
||||
}
|
||||
return target.position().add(AntarchyGravityRotationUtil.vecPlayerToWorld(
|
||||
0.0D,
|
||||
target.getEyeHeight() - 1.100000023841858D,
|
||||
0.0D,
|
||||
getGravityDirection(target)
|
||||
)).z;
|
||||
}
|
||||
|
||||
public static double rangedSqrt(double value, net.minecraft.world.entity.LivingEntity target) {
|
||||
return isGravityInverted(target) ? Math.sqrt(Math.sqrt(value)) : Math.sqrt(value);
|
||||
}
|
||||
|
||||
private static AntarchyGravityAccess access(Entity entity) {
|
||||
if (entity instanceof AntarchyGravityAccess access) {
|
||||
return access;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Entity " + entity + " is missing Antarchy gravity state");
|
||||
}
|
||||
|
||||
private static Vec3 projectileSpawnVec(net.minecraft.world.entity.LivingEntity shooter) {
|
||||
AntarchyGravityDirection direction = getGravityDirection(shooter);
|
||||
if (!direction.isInverted()) {
|
||||
return new Vec3(shooter.getX(), shooter.getEyeY() - 0.1D, shooter.getZ());
|
||||
}
|
||||
return shooter.getEyePosition().subtract(AntarchyGravityRotationUtil.vecPlayerToWorld(0.0D, 0.1D, 0.0D, direction));
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public enum AntarchyGravityDirection {
|
||||
DOWN(0, "down", false),
|
||||
UP(1, "up", true);
|
||||
|
||||
private final int id;
|
||||
private final String serializedName;
|
||||
private final boolean inverted;
|
||||
|
||||
AntarchyGravityDirection(int id, String serializedName, boolean inverted) {
|
||||
this.id = id;
|
||||
this.serializedName = serializedName;
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getSerializedName() {
|
||||
return this.serializedName;
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return this.inverted;
|
||||
}
|
||||
|
||||
public static AntarchyGravityDirection byId(int id) {
|
||||
return id == UP.id ? UP : DOWN;
|
||||
}
|
||||
|
||||
public static Optional<AntarchyGravityDirection> parse(String value) {
|
||||
for (AntarchyGravityDirection direction : values()) {
|
||||
if (direction.serializedName.equalsIgnoreCase(value)) {
|
||||
return Optional.of(direction);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
package com.craisinlord.antarchy.content.gravity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public final class AntarchyGravityRotationUtil {
|
||||
private AntarchyGravityRotationUtil() {
|
||||
}
|
||||
|
||||
public static Vec3 vecWorldToPlayer(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
return new Vec3(-vector.x, -vector.y, vector.z);
|
||||
}
|
||||
|
||||
public static Vec3 vecWorldToPlayer(double x, double y, double z, AntarchyGravityDirection direction) {
|
||||
return vecWorldToPlayer(new Vec3(x, y, z), direction);
|
||||
}
|
||||
|
||||
public static Vec3 vecPlayerToWorld(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
return new Vec3(-vector.x, -vector.y, vector.z);
|
||||
}
|
||||
|
||||
public static Vec3 vecPlayerToWorld(double x, double y, double z, AntarchyGravityDirection direction) {
|
||||
return vecPlayerToWorld(new Vec3(x, y, z), direction);
|
||||
}
|
||||
|
||||
public static Vec3 maskPlayerToWorld(Vec3 vector, AntarchyGravityDirection direction) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity, double eyeHeight) {
|
||||
return vecPlayerToWorld(new Vec3(0.0D, eyeHeight, 0.0D), AntarchyGravityApi.getGravityDirection(entity));
|
||||
}
|
||||
|
||||
public static Vec3 getEyeOffset(Entity entity, double eyeHeight, float partialTick) {
|
||||
AntarchyGravityDirection direction = AntarchyGravityApi.getGravityDirection(entity);
|
||||
if (!direction.isInverted() && AntarchyGravityApi.getGravityFlipProgress(entity, partialTick) <= 0.0F) {
|
||||
return new Vec3(0.0D, eyeHeight, 0.0D);
|
||||
}
|
||||
|
||||
Vector3f offset = new Vector3f(0.0F, (float) eyeHeight, 0.0F);
|
||||
offset.rotate(getWorldRotationQuaternion(entity, partialTick));
|
||||
return new Vec3(offset.x(), offset.y(), offset.z());
|
||||
}
|
||||
|
||||
public static AABB boxPlayerToWorld(AABB box, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return box;
|
||||
}
|
||||
|
||||
return new AABB(
|
||||
vecPlayerToWorld(new Vec3(box.minX, box.minY, box.minZ), direction),
|
||||
vecPlayerToWorld(new Vec3(box.maxX, box.maxY, box.maxZ), direction)
|
||||
);
|
||||
}
|
||||
|
||||
public static AABB boxWorldToPlayer(AABB box, AntarchyGravityDirection direction) {
|
||||
if (!direction.isInverted()) {
|
||||
return box;
|
||||
}
|
||||
|
||||
return new AABB(
|
||||
vecWorldToPlayer(new Vec3(box.minX, box.minY, box.minZ), direction),
|
||||
vecWorldToPlayer(new Vec3(box.maxX, box.maxY, box.maxZ), direction)
|
||||
);
|
||||
}
|
||||
|
||||
public static Quaternionf getWorldRotationQuaternion(Entity entity, float partialTick) {
|
||||
return rotationAroundNegativeZ(180.0F * AntarchyGravityApi.getGravityFlipProgress(entity, partialTick));
|
||||
}
|
||||
|
||||
public static Quaternionf getCameraRotationQuaternion(Entity entity, float partialTick) {
|
||||
return rotationAroundNegativeZ(-180.0F * AntarchyGravityApi.getGravityFlipProgress(entity, partialTick));
|
||||
}
|
||||
|
||||
public static Vec2 rotWorldToPlayer(float yaw, float pitch, AntarchyGravityDirection direction) {
|
||||
Vec3 vector = vecWorldToPlayer(rotToVec(yaw, pitch), direction);
|
||||
return vecToRot(vector);
|
||||
}
|
||||
|
||||
public static Vec2 rotPlayerToWorld(float yaw, float pitch, AntarchyGravityDirection direction) {
|
||||
Vec3 vector = vecPlayerToWorld(rotToVec(yaw, pitch), direction);
|
||||
return vecToRot(vector);
|
||||
}
|
||||
|
||||
public static Direction getGravityDownDirection(Entity entity) {
|
||||
return AntarchyGravityApi.isGravityInverted(entity) ? Direction.UP : Direction.DOWN;
|
||||
}
|
||||
|
||||
public static BlockPos getSupportingBlockPos(Entity entity, double offset) {
|
||||
Direction direction = getGravityDownDirection(entity);
|
||||
Vec3 pos = entity.position().add(
|
||||
direction.getStepX() * offset,
|
||||
direction.getStepY() * offset,
|
||||
direction.getStepZ() * offset
|
||||
);
|
||||
return BlockPos.containing(pos);
|
||||
}
|
||||
|
||||
private static Quaternionf rotationAroundNegativeZ(float degrees) {
|
||||
return new Quaternionf().fromAxisAngleDeg(0.0F, 0.0F, -1.0F, degrees);
|
||||
}
|
||||
|
||||
private static Vec3 rotToVec(float yaw, float pitch) {
|
||||
double radPitch = pitch * 0.017453292F;
|
||||
double radNegYaw = -yaw * 0.017453292F;
|
||||
double cosNegYaw = Math.cos(radNegYaw);
|
||||
double sinNegYaw = Math.sin(radNegYaw);
|
||||
double cosPitch = Math.cos(radPitch);
|
||||
double sinPitch = Math.sin(radPitch);
|
||||
return new Vec3(sinNegYaw * cosPitch, -sinPitch, cosNegYaw * cosPitch);
|
||||
}
|
||||
|
||||
private static Vec2 vecToRot(Vec3 vector) {
|
||||
double sinPitch = -vector.y;
|
||||
double radPitch = Math.asin(sinPitch);
|
||||
double cosPitch = Math.cos(radPitch);
|
||||
double sinNegYaw = vector.x / cosPitch;
|
||||
double cosNegYaw = Math.max(-1.0D, Math.min(1.0D, vector.z / cosPitch));
|
||||
double radNegYaw = Math.acos(cosNegYaw);
|
||||
if (sinNegYaw < 0.0D) {
|
||||
radNegYaw = Math.PI * 2.0D - radNegYaw;
|
||||
}
|
||||
|
||||
return new Vec2((float) (-radNegYaw / 0.017453292F), (float) (radPitch / 0.017453292F));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 341 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user