diff --git a/src/main/java/de/dafuqs/spectrum/compat/REI/REIClientIntegration.java b/src/main/java/de/dafuqs/spectrum/compat/REI/REIClientIntegration.java index 140ff3554a..b9b1d98f7b 100644 --- a/src/main/java/de/dafuqs/spectrum/compat/REI/REIClientIntegration.java +++ b/src/main/java/de/dafuqs/spectrum/compat/REI/REIClientIntegration.java @@ -108,7 +108,7 @@ public void registerCategories(CategoryRegistry registry) { @Override public void registerDisplays(DisplayRegistry registry) { - registry.registerFiller(AnvilCrushingRecipe.class, AnvilCrushingDisplay::new); + registry.registerRecipeFiller(AnvilCrushingRecipe.class, SpectrumRecipeTypes.ANVIL_CRUSHING, AnvilCrushingDisplay::new); registry.registerRecipeFiller(PedestalRecipe.class, SpectrumRecipeTypes.PEDESTAL, PedestalCraftingDisplay::new); registry.registerRecipeFiller(FusionShrineRecipe.class, SpectrumRecipeTypes.FUSION_SHRINE, FusionShrineDisplay::new); registry.registerRecipeFiller(EnchanterRecipe.class, SpectrumRecipeTypes.ENCHANTER, EnchanterEnchantingDisplay::new); diff --git a/src/main/java/de/dafuqs/spectrum/entity/SpectrumEntityTypes.java b/src/main/java/de/dafuqs/spectrum/entity/SpectrumEntityTypes.java index 86848cfd4d..333ac05937 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/SpectrumEntityTypes.java +++ b/src/main/java/de/dafuqs/spectrum/entity/SpectrumEntityTypes.java @@ -31,9 +31,9 @@ public class SpectrumEntityTypes { public static final EntityType LIGHT_SPEAR = register("light_spear", EntityType.Builder.create(LightSpearEntity::new, SpawnGroup.MISC).disableSaving().makeFireImmune().dimensions(0.75F, 0.75F).maxTrackingRange(4).trackingTickInterval(20)); public static final EntityType LIGHT_MINE = register("light_mine", EntityType.Builder.create(LightMineEntity::new, SpawnGroup.MISC).disableSaving().makeFireImmune().dimensions(0.75F, 0.75F).maxTrackingRange(4).trackingTickInterval(20)); public static final EntityType MONSTROSITY = register("monstrosity", EntityType.Builder.create(MonstrosityEntity::new, SpawnGroup.MISC).makeFireImmune().spawnableFarFromPlayer().dimensions(6.0F, 6.0F).maxTrackingRange(10)); - public static final EntityType PRESERVATION_TURRET = register("preservation_turret", EntityType.Builder.create(PreservationTurretEntity::new, SpawnGroup.MONSTER).makeFireImmune().spawnableFarFromPlayer().dimensions(1.0F, 1.0F).maxTrackingRange(10)); + public static final EntityType PRESERVATION_TURRET = register("preservation_turret", EntityType.Builder.create(PreservationTurretEntity::new, SpawnGroup.MONSTER).makeFireImmune().spawnableFarFromPlayer().dimensions(1.0F, 1.0F).vehicleAttachment().maxTrackingRange(10)); public static final EntityType LIZARD = register("lizard", EntityType.Builder.create(LizardEntity::new, SpawnGroup.MONSTER).dimensions(1.0F, 0.7F).maxTrackingRange(10)); - public static final EntityType KINDLING = register("kindling", EntityType.Builder.create(KindlingEntity::new, SpawnGroup.CREATURE).dimensions(1.0F, 1.0F).maxTrackingRange(10).makeFireImmune()); + public static final EntityType KINDLING = register("kindling", EntityType.Builder.create(KindlingEntity::new, SpawnGroup.CREATURE).dimensions(1.0F, 1.0F).passengerAttachments(0.5F).maxTrackingRange(10).makeFireImmune()); public static final EntityType KINDLING_COUGH = register("kindling_cough", EntityType.Builder.create(KindlingCoughEntity::new, SpawnGroup.MISC).dimensions(0.25F, 0.25F).maxTrackingRange(4).trackingTickInterval(10).makeFireImmune()); public static final EntityType ERASER = register("eraser", EntityType.Builder.create(EraserEntity::new, SpawnGroup.MONSTER).dimensions(0.3F, 0.3F).maxTrackingRange(10)); public static final EntityType ITEM_PROJECTILE = register("item_projectile", EntityType.Builder.create(ItemProjectileEntity::new, SpawnGroup.MISC).dimensions(0.25F, 0.25F).maxTrackingRange(6).trackingTickInterval(20)); diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/InkProjectileEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/InkProjectileEntity.java index 8920dde2f4..b8e8923efe 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/InkProjectileEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/InkProjectileEntity.java @@ -122,44 +122,41 @@ private void spawnParticles(int amount) { protected void onEntityHit(EntityHitResult entityHitResult) { super.onEntityHit(entityHitResult); - Entity entity = entityHitResult.getEntity(); + Entity target = entityHitResult.getEntity(); - if (EntityColorProcessorRegistry.colorEntity(entity, getInkColor().getDyeColor())) { - entity.getWorld().playSoundFromEntity(null, entity, SoundEvents.ITEM_DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F); + if (EntityColorProcessorRegistry.colorEntity(target, getInkColor().getDyeColor())) { + target.getWorld().playSoundFromEntity(null, target, SoundEvents.ITEM_DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F); } float velocity = (float) this.getVelocity().length(); int damage = MathHelper.ceil(MathHelper.clamp((double) velocity * DAMAGE_PER_POTENCY * SPELL_POTENCY, 0.0D, 2.147483647E9D)); - Entity entity2 = this.getOwner(); + Entity owner = this.getOwner(); DamageSource damageSource; - if (entity2 == null) { + if (owner == null) { damageSource = SpectrumDamageTypes.inkProjectile(this, this); } else { - damageSource = SpectrumDamageTypes.inkProjectile(this, entity2); - if (entity2 instanceof LivingEntity) { - ((LivingEntity) entity2).onAttacking(entity); + damageSource = SpectrumDamageTypes.inkProjectile(this, owner); + if (owner instanceof LivingEntity livingOwner) { + livingOwner.onAttacking(target); } } - if (entity.damage(damageSource, (float) damage)) { - if (entity instanceof LivingEntity livingEntity) { + if (target.damage(damageSource, (float) damage)) { + if (target instanceof LivingEntity livingTarget) { - if (!this.getWorld().isClient() && entity2 instanceof LivingEntity) { - EnchantmentHelper.onUserDamaged(livingEntity, entity2); - EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity); + if (this.getWorld() instanceof ServerWorld serverWorld) { + EnchantmentHelper.onTargetDamaged(serverWorld, target, damageSource, null); } - this.onHit(livingEntity); + this.onHit(livingTarget); - if (livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) { - ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F)); + if (target != owner && target instanceof PlayerEntity && owner instanceof ServerPlayerEntity ownerPlayer && !this.isSilent()) { + ownerPlayer.networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F)); } - if (!this.getWorld().isClient() && entity2 instanceof ServerPlayerEntity serverPlayerEntity) { - if (!entity.isAlive()) { - SpectrumAdvancementCriteria.KILLED_BY_INK_PROJECTILE.trigger(serverPlayerEntity, List.of(entity)); - } + if (owner instanceof ServerPlayerEntity ownerPlayer && !target.isAlive()) { + SpectrumAdvancementCriteria.KILLED_BY_INK_PROJECTILE.trigger(ownerPlayer, List.of(target)); } } @@ -221,23 +218,17 @@ protected void onHit(LivingEntity target) { if (colorOrdinal != -1) { //InkColor.all().get(colorOrdinal); - Entity entity = target; //this.getEffectCause(); - if(this.getInkColor() == InkColors.ORANGE) - { + if(this.getInkColor() == InkColors.ORANGE) { entity.setOnFireFor(2); - } - else - { + } else { // TODO: this is a dummy effect Vec3d vec3d = this.getVelocity().multiply(1.0D, 0.0D, 1.0D).normalize().multiply((double) 3 * 0.6D); if (vec3d.lengthSquared() > 0.0D) { entity.addVelocity(vec3d.x, 0.1D, vec3d.z); } } - - affectEntitiesInRange(this.getOwner()); @@ -288,7 +279,7 @@ public void affectEntitiesInRange(Entity attacker) { entity.getWorld().playSoundFromEntity(null, entity, SoundEvents.ITEM_DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F); } - if (!entity.isImmuneToExplosion()) { + if (!entity.isImmuneToExplosion(null)) { double w = Math.sqrt(entity.squaredDistanceTo(vec3d)) / (double) q; if (w <= 1.0D) { double x = entity.getX() - posX; @@ -300,17 +291,19 @@ public void affectEntitiesInRange(Entity attacker) { y /= aa; z /= aa; double ab = Explosion.getExposure(vec3d, entity); - double ac = (1.0D - w) * ab; + double velocity = (1.0D - w) * ab; //float damage = (float) ((int) ((ac * ac + ac) / 2.0D * (double) q + 1.0D)); //entity.damage(SpectrumDamageSources.inkProjectile(this, attacker), damage); - double ad = ac; if (entity instanceof LivingEntity livingEntity) { - ad = ProtectionEnchantment.transformExplosionKnockback(livingEntity, ac); + int i = SpectrumEnchantmentHelper.getEquipmentLevel(getWorld().getRegistryManager(), Enchantments.BLAST_PROTECTION, livingEntity); + if (i > 0) { + velocity *= MathHelper.clamp(1.0 - (double)i * 0.15, 0.0, 1.0); + } } - entity.setVelocity(entity.getVelocity().add(x * ad, y * ad, z * ad)); + entity.setVelocity(entity.getVelocity().add(x * velocity, y * velocity, z * velocity)); } } } diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/KindlingEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/KindlingEntity.java index 6585b068b2..fb94c9925a 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/KindlingEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/KindlingEntity.java @@ -43,8 +43,6 @@ public class KindlingEntity extends AbstractHorseEntity implements RangedAttackMob, Angerable, Shearable { - private static final UUID HORSE_ARMOR_BONUS_ID = UUID.fromString("f55b70e7-db42-4384-8843-6e9c843336af"); - protected static final TrackedData VARIANT = DataTracker.registerData(KindlingEntity.class, SpectrumTrackedDataHandlerRegistry.KINDLING_VARIANT); protected static final Ingredient FOOD = Ingredient.fromTag(SpectrumItemTags.KINDLING_FOOD); @@ -154,23 +152,15 @@ public void setKindlingVariant(KindlingVariant variant) { this.dataTracker.set(VARIANT, variant); } - @Override - public double getMountedHeightOffset() { - return super.getMountedHeightOffset() - 0.25; - } - @Override public void writeCustomDataToNbt(NbtCompound nbt) { super.writeCustomDataToNbt(nbt); this.writeAngerToNbt(nbt); - nbt.putString("variant", SpectrumRegistries.KINDLING_VARIANT.getId(this.getKindlingVariant()).toString()); + Optional.ofNullable(SpectrumRegistries.KINDLING_VARIANT.getId(this.getKindlingVariant())).ifPresent(id -> + nbt.putString("variant", id.toString())); nbt.putInt("chillTime", getChillTime()); nbt.putInt("eepyTime", getEepyTime()); nbt.putBoolean("playing", isPlaying()); - - if (!this.items.getStack(1).isEmpty()) { - nbt.put("ArmorItem", this.items.getStack(1).writeNbt(new NbtCompound())); - } } @Override @@ -186,13 +176,13 @@ public void readCustomDataFromNbt(NbtCompound nbt) { setPlaying(nbt.getBoolean("playing")); if (nbt.contains("ArmorItem", 10)) { - ItemStack itemStack = ItemStack.fromNbt(nbt.getCompound("ArmorItem")); + ItemStack itemStack = ItemStack.fromNbt(this.getRegistryManager(), nbt.getCompound("ArmorItem")).orElse(ItemStack.EMPTY); if (!itemStack.isEmpty() && this.isHorseArmor(itemStack)) { this.items.setStack(1, itemStack); } } - this.updateSaddle(); + this.updateSaddledFlag(); } @Override @@ -210,46 +200,18 @@ public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { return baby; } - public ItemStack getArmorType() { - return this.getEquippedStack(EquipmentSlot.CHEST); - } - - private void equipArmor(ItemStack stack) { - this.equipStack(EquipmentSlot.CHEST, stack); - this.setEquipmentDropChance(EquipmentSlot.CHEST, 0.0F); - } - - protected void updateSaddle() { - if (!this.getWorld().isClient) { - super.updateSaddle(); - this.setArmorTypeFromStack(this.items.getStack(1)); - this.setEquipmentDropChance(EquipmentSlot.CHEST, 0.0F); - } - } - - private void setArmorTypeFromStack(ItemStack stack) { - this.equipArmor(stack); - if (!this.getWorld().isClient) { - this.getAttributeInstance(EntityAttributes.GENERIC_ARMOR).removeModifier(HORSE_ARMOR_BONUS_ID); - if (this.isHorseArmor(stack)) { - int armorBonus = ((AnimalArmorItem) stack.getItem()).getBonus(); - if (armorBonus != 0) { - this.getAttributeInstance(EntityAttributes.GENERIC_ARMOR).addTemporaryModifier(new EntityAttributeModifier(HORSE_ARMOR_BONUS_ID, "Horse armor bonus", armorBonus, EntityAttributeModifier.Operation.ADD_VALUE)); - } - } - } - } - + @Override public void onInventoryChanged(Inventory sender) { - ItemStack itemStack = this.getArmorType(); + ItemStack itemStack = this.getBodyArmor(); super.onInventoryChanged(sender); - ItemStack itemStack2 = this.getArmorType(); + ItemStack itemStack2 = this.getBodyArmor(); if (this.age > 20 && this.isHorseArmor(itemStack2) && itemStack != itemStack2) { this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F); } } - public boolean hasArmorSlot() { + @Override + public boolean canUseSlot(EquipmentSlot slot) { return true; } @@ -700,7 +662,7 @@ public void takeRevenge(UUID target) { } @Override - public void attack(LivingEntity target, float pullProgress) { + public void shootAt(LivingEntity target, float pullProgress) { this.coughAt(target); } @@ -714,11 +676,6 @@ public boolean canBreedWith(AnimalEntity other) { return other != this && other instanceof KindlingEntity otherKindling && this.canBreed() && otherKindling.canBreed(); } - @Override - public EntityView method_48926() { - return this.getWorld(); - } - protected class CoughRevengeGoal extends RevengeGoal { public CoughRevengeGoal(KindlingEntity kindling) { @@ -795,9 +752,8 @@ public boolean shouldContinue() { } @Override - protected void attack(LivingEntity target, double squaredDistance) { - double d = this.getSquaredMaxAttackDistance(target); - if (squaredDistance <= d && this.getCooldown() <= 0) { + protected void attack(LivingEntity target) { + if (this.canAttack(target)) { this.resetCooldown(); this.mob.swingHand(Hand.MAIN_HAND); this.mob.tryAttack(target); diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/LightMineEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/LightMineEntity.java index ea584c3cf2..1f13d6270b 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/LightMineEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/LightMineEntity.java @@ -3,6 +3,8 @@ import com.google.common.collect.*; import de.dafuqs.spectrum.*; import de.dafuqs.spectrum.entity.*; +import de.dafuqs.spectrum.helpers.*; +import net.minecraft.component.type.*; import net.minecraft.entity.*; import net.minecraft.entity.data.*; import net.minecraft.entity.effect.*; @@ -50,7 +52,7 @@ public void setEffects(List effects) { if (this.effects.isEmpty()) { setColor(16777215); } else { - setColor(PotionUtil.getColor(this.effects)); + setColor(PotionContentsComponent.getColor(this.effects)); } } @@ -71,11 +73,7 @@ protected void writeCustomDataToNbt(NbtCompound nbt) { nbt.putInt("Color", this.getColor()); } if (!this.effects.isEmpty()) { - NbtList nbtList = new NbtList(); - for (StatusEffectInstance statusEffectInstance : this.effects) { - nbtList.add(statusEffectInstance.writeNbt(new NbtCompound())); - } - nbt.put("CustomPotionEffects", nbtList); + CodecHelper.writeNbt(nbt, "CustomPotionEffects", StatusEffectInstance.CODEC.listOf(), this.effects.stream().toList()); } } @@ -83,7 +81,7 @@ protected void writeCustomDataToNbt(NbtCompound nbt) { protected void readCustomDataFromNbt(NbtCompound nbt) { super.readCustomDataFromNbt(nbt); - this.setEffects(PotionUtil.getCustomPotionEffects(nbt)); + this.setEffects(CodecHelper.fromNbt(StatusEffectInstance.CODEC.listOf(), nbt.get("CustomPotionEffects"), List.of())); if (nbt.contains("Color", NbtElement.NUMBER_TYPE)) { this.setColor(nbt.getInt("Color")); @@ -92,7 +90,7 @@ protected void readCustomDataFromNbt(NbtCompound nbt) { if (this.effects.isEmpty()) { this.dataTracker.set(COLOR, NO_POTION_COLOR); } else { - this.dataTracker.set(COLOR, PotionUtil.getColor(this.effects)); + this.dataTracker.set(COLOR, PotionContentsComponent.getColor(this.effects)); } } } @@ -119,10 +117,7 @@ public void tick() { private void spawnParticles() { if (!this.effects.isEmpty()) { int color = this.getColor(); - double d = (double) (color >> 16 & 255) / 255.0; - double e = (double) (color >> 8 & 255) / 255.0; - double f = (double) (color & 255) / 255.0; - this.getWorld().addParticle(ParticleTypes.ENTITY_EFFECT, this.getParticleX(0.5), this.getRandomBodyY(), this.getParticleZ(0.5), d, e, f); + this.getWorld().addParticle(EntityEffectParticleEffect.create(ParticleTypes.ENTITY_EFFECT, color), this.getParticleX(0.5), this.getRandomBodyY(), this.getParticleZ(0.5), 0.0, 0.0, 0.0); } } diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/LightShardEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/LightShardEntity.java index 4b9531a089..e9d652ac6a 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/LightShardEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/LightShardEntity.java @@ -48,7 +48,7 @@ public Identifier getTexture() { } static { - SPRITES = Identifier.of[4]; + SPRITES = new Identifier[4]; SPRITES[0] = SpectrumCommon.locate("textures/entity/projectile/light_shard_0.png"); SPRITES[1] = SpectrumCommon.locate("textures/entity/projectile/light_shard_1.png"); SPRITES[2] = SpectrumCommon.locate("textures/entity/projectile/light_shard_2.png"); diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/MiningProjectileEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/MiningProjectileEntity.java index 2b1a48a55b..17d1efea37 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/MiningProjectileEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/MiningProjectileEntity.java @@ -78,7 +78,7 @@ protected void onBlockHit(BlockHitResult blockHitResult) { if (entity instanceof PlayerEntity player) { Predicate minablePredicate = state -> { int miningLevel = this.toolStack.getItem() instanceof ToolItem toolItem ? toolItem.getMaterial().getMiningLevel() : 1; - int efficiency = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, this.toolStack); + int efficiency = SpectrumEnchantmentHelper.getLevel(getWorld().getRegistryManager(), Enchantments.EFFICIENCY, this.toolStack); return state.getBlock().getHardness() <= miningLevel + efficiency; }; AoEHelper.breakBlocksAround(player, this.toolStack, blockHitResult.getBlockPos(), MINING_RANGE, minablePredicate); diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/MoltenFishingBobberEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/MoltenFishingBobberEntity.java index ea9c31267f..8dbf16cdcf 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/MoltenFishingBobberEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/MoltenFishingBobberEntity.java @@ -23,7 +23,7 @@ public void tick() { } } - public MoltenFishingBobberEntity(PlayerEntity thrower, World world, int luckBonus, float waitTimeReductionTicks, int exuberanceLevel, int bigCatchLevel, int serendipityReelLevel, boolean inventoryInsertion) { + public MoltenFishingBobberEntity(PlayerEntity thrower, World world, int luckBonus, int waitTimeReductionTicks, int exuberanceLevel, int bigCatchLevel, int serendipityReelLevel, boolean inventoryInsertion) { super(SpectrumEntityTypes.MOLTEN_FISHING_BOBBER, thrower, world, luckBonus, waitTimeReductionTicks, exuberanceLevel, bigCatchLevel, serendipityReelLevel, inventoryInsertion, true); } diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/MonstrosityEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/MonstrosityEntity.java index 99324b2b5a..7d9ebf5b8e 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/MonstrosityEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/MonstrosityEntity.java @@ -163,7 +163,7 @@ public void tick() { if (this.hasInvincibilityTicks()) { for (int j = 0; j < 3; ++j) { - this.getWorld().addParticle(ParticleTypes.ENTITY_EFFECT, this.getX() + this.random.nextGaussian(), this.getY() + (double) (this.random.nextFloat() * 3.3F), this.getZ() + this.random.nextGaussian(), 0.7, 0.7, 0.7); + this.getWorld().addParticle(EntityEffectParticleEffect.create(ParticleTypes.ENTITY_EFFECT, 0.7f, 0.7f, 0.7f), this.getX() + this.random.nextGaussian(), this.getY() + (double) (this.random.nextFloat() * 3.3F), this.getZ() + this.random.nextGaussian(), 0.0, 0.0, 0.0); } } } diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/PreservationTurretEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/PreservationTurretEntity.java index cf1d428d55..8acf3dfb29 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/PreservationTurretEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/PreservationTurretEntity.java @@ -194,9 +194,11 @@ private void tickOpenProgress() { } @Override - public double getHeightOffset() { - EntityType vehicleType = this.getVehicle().getType(); - return vehicleType != EntityType.BOAT && vehicleType != EntityType.MINECART ? super.getHeightOffset() : 0.1875 - this.getVehicle().getMountedHeightOffset(); + public Vec3d getVehicleAttachmentPos(Entity vehicle) { + if (vehicle.getType() != EntityType.BOAT && vehicle.getType() != EntityType.MINECART) + return super.getVehicleAttachmentPos(vehicle); + var ridingPos = vehicle.getPassengerRidingPos(this); + return new Vec3d(ridingPos.x, 0.1875 - ridingPos.y, ridingPos.z); } @Override diff --git a/src/main/java/de/dafuqs/spectrum/entity/entity/SpectrumBossEntity.java b/src/main/java/de/dafuqs/spectrum/entity/entity/SpectrumBossEntity.java index 4ce07d5168..6f79d88b58 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/entity/SpectrumBossEntity.java +++ b/src/main/java/de/dafuqs/spectrum/entity/entity/SpectrumBossEntity.java @@ -250,7 +250,7 @@ public LivingEntity.FallSounds getFallSounds() { } @Override - public boolean canBeLeashedBy(PlayerEntity player) { + public boolean canBeLeashed() { return false; } diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/KindlingEntityArmorFeatureRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/KindlingEntityArmorFeatureRenderer.java index 92840ff55a..5ba8bfccab 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/KindlingEntityArmorFeatureRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/KindlingEntityArmorFeatureRenderer.java @@ -9,8 +9,11 @@ import net.minecraft.client.render.entity.feature.*; import net.minecraft.client.render.entity.model.*; import net.minecraft.client.util.math.*; +import net.minecraft.component.type.*; import net.minecraft.item.*; +import net.minecraft.registry.tag.*; import net.minecraft.util.*; +import net.minecraft.util.math.*; @Environment(EnvType.CLIENT) public class KindlingEntityArmorFeatureRenderer extends FeatureRenderer { @@ -29,28 +32,15 @@ public KindlingEntityArmorFeatureRenderer(FeatureRendererContext> 16 & 255) / 255.0F; - green = (float) (color >> 8 & 255) / 255.0F; - blue = (float) (color & 255) / 255.0F; - } else { - red = 1.0F; - green = 1.0F; - blue = 1.0F; - } - - VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutoutNoCull(getTextureForArmor(horseArmorItem))); - this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, red, green, blue, 1.0F); + var color = itemStack.isIn(ItemTags.DYEABLE) ? ColorHelper.Argb.fullAlpha(DyedColorComponent.getColor(itemStack, DyedColorComponent.DEFAULT_COLOR)) : -1; + VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutoutNoCull(getTextureForArmor(armorItem))); + this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, color); } } diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/LightMineEntityRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/LightMineEntityRenderer.java index 4a79f66833..b85a21ab87 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/LightMineEntityRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/LightMineEntityRenderer.java @@ -33,13 +33,12 @@ public void render(LightMineEntity mine, float yaw, float tickDelta, MatrixStack var consumer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentCull(getTexture(mine))); var matrix = matrices.peek(); var positions = matrix.getPositionMatrix(); - var normals = matrix.getNormalMatrix(); Vector3f color = ColorHelper.colorIntToVec(mine.getColor()); - consumer.vertex(positions, 0, 0, 0).color(color.x(), color.y(), color.z(), alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 0, 0).color(color.x(), color.y(), color.z(), alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 1, 0).color(color.x(), color.y(), color.z(), alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 0, 1, 0).color(color.x(), color.y(), color.z(), alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); + consumer.vertex(positions, 0, 0, 0).color(color.x(), color.y(), color.z(), alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 0, 0).color(color.x(), color.y(), color.z(), alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 1, 0).color(color.x(), color.y(), color.z(), alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 0, 1, 0).color(color.x(), color.y(), color.z(), alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); matrices.pop(); diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/LightShardEntityRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/LightShardEntityRenderer.java index 5d39db5842..60039818d7 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/LightShardEntityRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/LightShardEntityRenderer.java @@ -31,12 +31,11 @@ public void render(LightShardEntity shard, float yaw, float tickDelta, MatrixSta var consumer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentCull(getTexture(shard))); var matrix = matrices.peek(); var positions = matrix.getPositionMatrix(); - var normals = matrix.getNormalMatrix(); - consumer.vertex(positions, 0, 0, 0).color(1f, 1f, 1f, alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 0, 0).color(1f, 1f, 1f, alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 1, 0).color(1f, 1f, 1f, alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 0, 1, 0).color(1f, 1f, 1f, alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); + consumer.vertex(positions, 0, 0, 0).color(1f, 1f, 1f, alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 0, 0).color(1f, 1f, 1f, alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 1, 0).color(1f, 1f, 1f, alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 0, 1, 0).color(1f, 1f, 1f, alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); matrices.pop(); diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/LightSpearEntityRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/LightSpearEntityRenderer.java index e045348f07..6d0e69c425 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/LightSpearEntityRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/LightSpearEntityRenderer.java @@ -33,12 +33,11 @@ public void render(LightShardBaseEntity shard, float yaw, float tickDelta, Matri var consumer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentCull(getTexture(shard))); var matrix = matrices.peek(); var positions = matrix.getPositionMatrix(); - var normals = matrix.getNormalMatrix(); - consumer.vertex(positions, 0, 0, 0).color(1f, 1f, 1f, alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 0, 0).color(1f, 1f, 1f, alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 1, 1, 0).color(1f, 1f, 1f, alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); - consumer.vertex(positions, 0, 1, 0).color(1f, 1f, 1f, alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(normals, 0, 1, 0).next(); + consumer.vertex(positions, 0, 0, 0).color(1f, 1f, 1f, alpha).texture(0, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 0, 0).color(1f, 1f, 1f, alpha).texture(1, 1).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 1, 1, 0).color(1f, 1f, 1f, alpha).texture(1, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); + consumer.vertex(positions, 0, 1, 0).color(1f, 1f, 1f, alpha).texture(0, 0).overlay(OverlayTexture.DEFAULT_UV).light(LightmapTextureManager.MAX_LIGHT_COORDINATE).normal(matrix, 0, 1, 0); matrices.pop(); diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/LizardFrillsFeatureRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/LizardFrillsFeatureRenderer.java index ad9a43c9be..a41d7c9a27 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/LizardFrillsFeatureRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/LizardFrillsFeatureRenderer.java @@ -8,7 +8,6 @@ import net.minecraft.client.render.*; import net.minecraft.client.render.entity.feature.*; import net.minecraft.client.util.math.*; -import org.joml.*; @Environment(EnvType.CLIENT) public class LizardFrillsFeatureRenderer extends FeatureRenderer> { @@ -21,9 +20,9 @@ public LizardFrillsFeatureRenderer(FeatureRendererContext extends FeatureRenderer> { @@ -22,9 +21,9 @@ public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, LizardHornVariant horns = lizard.getHorns(); if (horns != LizardHornVariant.ONLY_LIKES_YOU_AS_A_FRIEND) { - VertexConsumer vertexConsumer = vertexConsumers.getBuffer(SpectrumRenderLayers.GlowInTheDarkRenderLayer.get(horns.texture())); - Vector3f color = lizard.getColor().getColorVec(); - this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, color.x(), color.y(), color.z(), 1.0F); + VertexConsumer vertexConsumer = vertexConsumers.getBuffer(SpectrumRenderLayers.GlowInTheDarkRenderLayer.get(horns.getTexture())); + var color = lizard.getColor().getColorInt(); + this.getContextModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, color); } } diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/MagicProjectileEntityRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/MagicProjectileEntityRenderer.java index cb4f0d2149..195c281cec 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/MagicProjectileEntityRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/MagicProjectileEntityRenderer.java @@ -40,21 +40,20 @@ public void render(MagicProjectileEntity magicProjectileEntity, float yaw, float int u = (int) (starColor.z() * 255.0F); MatrixStack.Entry entry = matrixStack.peek(); Matrix4f matrix4f = entry.getPositionMatrix(); - Matrix3f matrix3f = entry.getNormalMatrix(); matrixStack.translate(0.0D, 0.10000000149011612D, 0.0D); matrixStack.multiply(this.dispatcher.getRotation()); matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); - vertex(vertexConsumer, matrix4f, matrix3f, -0.5F, -0.25F, s, t, u, h, m, light); - vertex(vertexConsumer, matrix4f, matrix3f, 0.5F, -0.25F, s, t, u, k, m, light); - vertex(vertexConsumer, matrix4f, matrix3f, 0.5F, 0.75F, s, t, u, k, l, light); - vertex(vertexConsumer, matrix4f, matrix3f, -0.5F, 0.75F, s, t, u, h, l, light); + vertex(vertexConsumer, entry, matrix4f, -0.5F, -0.25F, s, t, u, h, m, light); + vertex(vertexConsumer, entry, matrix4f, 0.5F, -0.25F, s, t, u, k, m, light); + vertex(vertexConsumer, entry, matrix4f, 0.5F, 0.75F, s, t, u, k, l, light); + vertex(vertexConsumer, entry, matrix4f, -0.5F, 0.75F, s, t, u, h, l, light); matrixStack.pop(); } - private static void vertex(VertexConsumer vertexConsumer, Matrix4f positionMatrix, Matrix3f normalMatrix, float x, float y, int red, int green, int blue, float u, float v, int light) { - vertexConsumer.vertex(positionMatrix, x, y, 0.0F).color(red, green, blue, 128).texture(u, v).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).next(); + private static void vertex(VertexConsumer vertexConsumer, MatrixStack.Entry matrix, Matrix4f positionMatrix, float x, float y, int red, int green, int blue, float u, float v, int light) { + vertexConsumer.vertex(positionMatrix, x, y, 0.0F).color(red, green, blue, 128).texture(u, v).overlay(OverlayTexture.DEFAULT_UV).light(light).normal(matrix, 0.0F, 1.0F, 0.0F); } @Override diff --git a/src/main/java/de/dafuqs/spectrum/entity/render/PreservationTurretEntityRenderer.java b/src/main/java/de/dafuqs/spectrum/entity/render/PreservationTurretEntityRenderer.java index 9369e205e3..8dec9268b9 100644 --- a/src/main/java/de/dafuqs/spectrum/entity/render/PreservationTurretEntityRenderer.java +++ b/src/main/java/de/dafuqs/spectrum/entity/render/PreservationTurretEntityRenderer.java @@ -24,11 +24,11 @@ public Identifier getTexture(PreservationTurretEntity turretEntity) { } @Override - protected void setupTransforms(PreservationTurretEntity turretEntity, MatrixStack matrixStack, float f, float g, float h) { - super.setupTransforms(turretEntity, matrixStack, f, g + 180.0F, h); - matrixStack.translate(0.0, 0.5, 0.0); - matrixStack.multiply(turretEntity.getAttachedFace().getOpposite().getRotationQuaternion()); - matrixStack.translate(0.0, -0.5, 0.0); + protected void setupTransforms(PreservationTurretEntity turretEntity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) { + super.setupTransforms(turretEntity, matrices, animationProgress, bodyYaw + 180.0F, tickDelta, scale); + matrices.translate(0.0, 0.5, 0.0); + matrices.multiply(turretEntity.getAttachedFace().getOpposite().getRotationQuaternion()); + matrices.translate(0.0, -0.5, 0.0); } } \ No newline at end of file diff --git a/src/main/java/de/dafuqs/spectrum/items/magic_items/EnderSpliceItem.java b/src/main/java/de/dafuqs/spectrum/items/magic_items/EnderSpliceItem.java index 02afd6b7d1..0416ba6e6f 100644 --- a/src/main/java/de/dafuqs/spectrum/items/magic_items/EnderSpliceItem.java +++ b/src/main/java/de/dafuqs/spectrum/items/magic_items/EnderSpliceItem.java @@ -130,7 +130,7 @@ private boolean teleportPlayerToPos(World world, LivingEntity user, PlayerEntity world.playSound(playerEntity, currentPos.getX(), currentPos.getY(), currentPos.getZ(), SpectrumSoundEvents.PLAYER_TELEPORTS, SoundCategory.PLAYERS, 1.0F, 1.0F); if (!isSameWorld) { - user.teleportTo(new TeleportTarget(targetWorld, targetPos.add(0, 0.25, 0), new Vec3d(0, 0, 0), user.getYaw(), user.getPitch())); + user.teleportTo(new TeleportTarget(targetWorld, targetPos.add(0, 0.25, 0), new Vec3d(0, 0, 0), user.getYaw(), user.getPitch(), TeleportTarget.NO_OP)); } else { user.requestTeleport(targetPos.getX(), targetPos.y + 0.25, targetPos.z); // +0.25 makes it look way more lively } diff --git a/src/main/java/de/dafuqs/spectrum/progression/advancement/InkProjectileKillingCriterion.java b/src/main/java/de/dafuqs/spectrum/progression/advancement/InkProjectileKillingCriterion.java index 1ee10d8f0e..7bc301e9b9 100644 --- a/src/main/java/de/dafuqs/spectrum/progression/advancement/InkProjectileKillingCriterion.java +++ b/src/main/java/de/dafuqs/spectrum/progression/advancement/InkProjectileKillingCriterion.java @@ -5,9 +5,11 @@ import com.mojang.serialization.codecs.*; import de.dafuqs.spectrum.*; import net.minecraft.advancement.criterion.*; +import net.minecraft.entity.*; import net.minecraft.loot.context.*; import net.minecraft.predicate.NumberRange.*; import net.minecraft.predicate.entity.*; +import net.minecraft.server.network.*; import net.minecraft.util.*; import java.util.*; @@ -21,6 +23,18 @@ public Codec getConditionsCodec() { return Conditions.CODEC; } + public void trigger(ServerPlayerEntity player, List piercingKilledEntities) { + List list = Lists.newArrayList(); + Set> set = Sets.newHashSet(); + + for (Entity entity : piercingKilledEntities) { + set.add(entity.getType()); + list.add(EntityPredicate.createAdvancementEntityLootContext(player, entity)); + } + + this.trigger(player, (conditions) -> conditions.matches(list, set.size())); + } + public record Conditions( Optional player, List victims, @@ -33,7 +47,6 @@ public record Conditions( IntRange.CODEC.fieldOf("unique_entity_types").forGetter(Conditions::uniqueEntities) ).apply(instance, Conditions::new)); - public boolean matches(Collection victimContexts, int uniqueEntityTypeCount) { if (!this.victims.isEmpty()) { List list = Lists.newArrayList(victimContexts);