Skip to content

Commit

Permalink
Merge branch '1.20.1-aria-for-painters' into 1.20.1-go-on-cry-you-can…
Browse files Browse the repository at this point in the history
…'t-unpiss-the-pastel-network

"Fluid" Transfer Pastel Nodes will be real in 2027
  • Loading branch information
Azzyypaaras committed Jan 14, 2025
2 parents a760175 + 95a2428 commit 48bd4ed
Show file tree
Hide file tree
Showing 114 changed files with 878 additions and 319 deletions.
11 changes: 11 additions & 0 deletions src/main/java/de/dafuqs/spectrum/api/color/ItemColors.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public class ItemColors extends ColorRegistry<Item> {
put(Items.GOLDEN_HORSE_ARMOR, DyeColor.YELLOW);
put(Items.LEATHER_HORSE_ARMOR, DyeColor.BROWN);

put(Items.BEEF, DyeColor.PINK);
put(Items.CHICKEN, DyeColor.PINK);
put(Items.MUTTON, DyeColor.PINK);
put(Items.PORKCHOP, DyeColor.PINK);
put(Items.RABBIT, DyeColor.PINK);
put(Items.COOKED_BEEF, DyeColor.PINK);
put(Items.COOKED_CHICKEN, DyeColor.PINK);
put(Items.COOKED_MUTTON, DyeColor.PINK);
put(Items.COOKED_PORKCHOP, DyeColor.PINK);
put(Items.COOKED_RABBIT, DyeColor.PINK);

put(Items.ANVIL, DyeColor.BROWN);
put(Items.BLACKSTONE, DyeColor.BLACK);
put(Items.GILDED_BLACKSTONE, DyeColor.BLACK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import de.dafuqs.spectrum.api.energy.color.*;
import net.fabricmc.api.*;
import net.minecraft.nbt.*;
import net.minecraft.registry.entry.*;
import net.minecraft.text.*;
import org.jetbrains.annotations.*;

Expand Down Expand Up @@ -123,13 +122,6 @@ public long getEnergy(InkColor color) {
return maxAmount;
}

public NbtCompound toNbt() {
NbtCompound compound = new NbtCompound();
compound.putLong("MaxEnergyTotal", this.maxEnergyTotal);
compound.put("Energy", InkStorage.writeEnergy(this.storedEnergy));
return compound;
}

public static TotalCappedElementalMixingInkStorage fromNbt(@NotNull NbtCompound compound) {
long maxEnergyTotal = compound.getLong("MaxEnergyTotal");
Map<InkColor, Long> energy = InkStorage.readEnergy(compound.contains("Energy") ? compound.getCompound("Energy") : compound);
Expand All @@ -139,14 +131,19 @@ public static TotalCappedElementalMixingInkStorage fromNbt(@NotNull NbtCompound
@Override
public void fillCompletely() {
this.storedEnergy.clear();
//try{
List<InkColor> elementals = InkColors.elementals();
if (elementals.isEmpty()) {
// in case the tag is empty or something queries that method
// before tags are fully synced
// looking at you, Mouse Wheelie
return;
}

long energyPerColor = this.maxEnergyTotal / elementals.size();
for (InkColor color : elementals) {
this.storedEnergy.put(color, energyPerColor);
}
this.currentTotal = energyPerColor * elementals.size(); // in case rounding is weird
//} catch (Exception e) {e.printStackTrace();}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface OmniAcceleratorProjectile {
OmniAcceleratorProjectile DEFAULT = (stack, shooter, world) -> {
ItemProjectileEntity itemProjectileEntity = new ItemProjectileEntity(world, shooter);
itemProjectileEntity.setItem(stack);
itemProjectileEntity.setVelocity(shooter, shooter.getPitch(), shooter.getYaw(), 0.0F, 2.0F, 0.5F);
itemProjectileEntity.setVelocity(shooter, shooter.getPitch(), shooter.getYaw(), 0.0F, 2.5F, 0.5F);
world.spawnEntity(itemProjectileEntity);
return itemProjectileEntity;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import de.dafuqs.spectrum.mixin.accessors.*;
import de.dafuqs.spectrum.registries.SpectrumStatusEffects;
import de.dafuqs.spectrum.registries.SpectrumStatusEffectTags;
import net.minecraft.entity.*;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.network.packet.s2c.play.*;
Expand All @@ -16,7 +16,7 @@ public interface Incurable {

static boolean isIncurable(StatusEffectInstance instance) {
var type = instance.getEffectType();
if (type == SpectrumStatusEffects.ETERNAL_SLUMBER || type == SpectrumStatusEffects.FATAL_SLUMBER)
if (SpectrumStatusEffectTags.cannotBeIncurable(type))
return false;

return ((Incurable) instance).spectrum$isIncurable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,19 @@
import de.dafuqs.spectrum.particle.*;
import de.dafuqs.spectrum.registries.*;
import net.fabricmc.fabric.api.screenhandler.v1.*;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.item.*;
import net.minecraft.block.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.registry.*;
import net.minecraft.screen.*;
import net.minecraft.server.network.*;
import net.minecraft.server.world.*;
import net.minecraft.sound.*;
import net.minecraft.text.*;
import net.minecraft.util.*;
import net.minecraft.util.collection.*;
import net.minecraft.util.math.*;
import net.minecraft.world.*;
Expand All @@ -44,7 +42,7 @@ public class BlackHoleChestBlockEntity extends SpectrumChestBlockEntity implemen
private static final int RANGE = 12;
private final ItemAndExperienceEventQueue itemAndExperienceEventQueue;
private final List<ItemVariant> filterItems;
private State state;
private State state = State.CLOSED_INACTIVE;
private boolean isOpen, isFull, hasXPStorage;
float storageTarget, storagePos, lastStorageTarget, capTarget, capPos, lastCapTarget, orbTarget, orbPos, lastOrbTarget, yawTarget, orbYaw, lastYawTarget;
long interpTicks, interpLength = 1, age, storedXP, maxStoredXP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RestockingChestBlockEntity extends SpectrumChestBlockEntity impleme
private List<ItemStack> cachedOutputs = new ArrayList<>(4);
private int coolDownTicks = 0;
private boolean isOpen, isFull, hasValidRecipes;
private State state;
private State state = State.CLOSED;
float rimTarget, rimPos, lastRimTarget, tabletTarget, tabletPos, lastTabletTarget,assemblyTarget, assemblyPos, lastAssemblyTarget, ringTarget, ringPos, lastRingTarget, itemTarget, itemPos, lastItemTarget, alphaTarget, alphaValue, lastAlphaTarget, yawModTarget, yawMod, lastYawModTarget, yaw, lastYaw;
long interpTicks, interpLength = 1, age;

Expand All @@ -40,7 +40,7 @@ public RestockingChestBlockEntity(BlockPos blockPos, BlockState blockState) {

public static void tick(World world, BlockPos pos, BlockState state, RestockingChestBlockEntity chest) {
chest.age++;

// TODO: that should run in `clientTick() instead` (same for other chests)
if (world.isClient) {

chest.lastYaw = chest.yaw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (world.getBlockState(pos.up()).isOf(this) || !isValidBlock(world, pos.up())) {
if (world.getBlockState(pos.up()).isOf(this) || !canGrow(world, pos.up())) {
return;
}

Expand Down Expand Up @@ -242,7 +242,6 @@ private boolean isValidBlock(WorldView world, BlockPos pos) {
if (!downState.isIn(SpectrumBlockTags.QUITOXIC_REEDS_PLANTABLE)) {
return false;
}

BlockState upState = world.getBlockState(pos.up());
BlockState upState2 = world.getBlockState(pos.up(2));
if (!upState.isOf(this)) {
Expand All @@ -260,6 +259,15 @@ private boolean isValidBlock(WorldView world, BlockPos pos) {
return fluidState.getLevel() == 8 && (fluidState.isIn(FluidTags.WATER) || state.isOf(SpectrumBlocks.LIQUID_CRYSTAL));
}

private boolean canGrow(WorldView world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
if (state.isAir()) {
return true;
}
FluidState fluidState = world.getFluidState(pos);
return fluidState.getLevel() == 8 && (fluidState.isIn(FluidTags.WATER) || state.isOf(SpectrumBlocks.LIQUID_CRYSTAL));
}

@Override
public float getMaxHorizontalModelOffset() {
return 0.15F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isSolidBlock(world, pos);
}

@Override
@SuppressWarnings("deprecation")
public VoxelShape getCameraCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
}

@Override
@SuppressWarnings("deprecation")
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
Expand Down Expand Up @@ -94,7 +88,7 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
if (this.isVisibleTo(context)) {
return SHAPE;
}
return VoxelShapes.fullCube();
return VoxelShapes.empty();
}

@Override
Expand All @@ -106,7 +100,7 @@ public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos
return this.isVisibleTo(player) ? SHAPE : VoxelShapes.empty();
}
}
return VoxelShapes.fullCube();
return VoxelShapes.empty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static boolean isValidCenterEnchantingSetup(@NotNull EnchanterBlockEntity
}

public static void playCraftingFinishedEffects(@NotNull EnchanterBlockEntity enchanterBlockEntity) {
enchanterBlockEntity.getWorld().playSound(null, enchanterBlockEntity.pos, SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.BLOCKS, 1.0F, 1.0F);
enchanterBlockEntity.getWorld().playSound(null, enchanterBlockEntity.pos, SpectrumSoundEvents.ENCHANTER_FINISH, SoundCategory.BLOCKS, 1.0F, 1.0F);

SpectrumS2CPacketSender.playParticleWithRandomOffsetAndVelocity((ServerWorld) enchanterBlockEntity.getWorld(),
new Vec3d(enchanterBlockEntity.pos.getX() + 0.5D, enchanterBlockEntity.pos.getY() + 0.5, enchanterBlockEntity.pos.getZ() + 0.5D),
Expand Down Expand Up @@ -421,7 +421,7 @@ public static int getRequiredExperienceForEnchantment(int enchantability, Enchan
default -> rarityCost = 80;
}

float levelCost = level + ((float) level / enchantment.getMaxLevel()); // the higher the level, the pricier. But not as bad for enchantments with high max levels
float levelCost = level * Math.min(1, (float) level / enchantment.getMaxLevel()); // the higher the level, the pricier. But not as bad for enchantments with high max levels
float specialMulti = enchantment.isTreasure() ? 2.0F : enchantment.isCursed() ? 1.5F : 1.0F;
float selectionAvailabilityMod = 1.0F;
if (!(enchantment instanceof SpectrumEnchantment)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean trigger(ServerWorld world, BlockPos blockPos, BlockState state, @
InWorldInteractionHelper.decrementAndSpawnRemainder(itemEntity, 1);

animalEntity.setLoveTicks(LOVE_TICKS);
world.sendEntityStatus(animalEntity, (byte) 18);
world.sendEntityStatus(animalEntity, EntityStatuses.ADD_BREEDING_PARTICLES);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static boolean teleportTo(ServerWorld world, Entity entity, BlockPos bloc
double boundingBoxY = entity.getBoundingBox().getYLength(); // bouncy
if (entity instanceof ServerPlayerEntity serverPlayerEntity) {
serverPlayerEntity.teleport((ServerWorld) serverPlayerEntity.getWorld(), mutable.getX() + 0.5, mutable.getY() + boundingBoxY, mutable.getZ() + 0.5, serverPlayerEntity.getYaw(), serverPlayerEntity.getPitch());
world.sendEntityStatus(serverPlayerEntity, (byte) 46); // particles
world.sendEntityStatus(serverPlayerEntity, EntityStatuses.ADD_BREEDING_PARTICLES);
return true;
} else if (entity instanceof LivingEntity livingEntity) {
boolean success = livingEntity.teleport(mutable.getX() + 0.5, mutable.getY() + boundingBoxY, mutable.getZ() + 0.5, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void spawnOrbParticles(Vec3d orbTargetPos) {
clientWorld.addParticle(sphereParticleEffect, this.pos.getX() + 0.5D, this.pos.getY() + 1.0D, this.pos.getZ() + 0.5D, (orbTargetPos.getX() - this.pos.getX()) * 0.045, 0, (orbTargetPos.getZ() - this.pos.getZ()) * 0.045);
}

world.playSound(null, this.pos, SpectrumSoundEvents.ENCHANTER_DING, SoundCategory.BLOCKS, SpectrumCommon.CONFIG.BlockSoundVolume, 0.7F + world.random.nextFloat() * 0.6F);
world.playSound(null, this.pos, SpectrumSoundEvents.CRAFTING_DING, SoundCategory.BLOCKS, SpectrumCommon.CONFIG.BlockSoundVolume, 0.7F + world.random.nextFloat() * 0.6F);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ private boolean filter(ItemVariant variant) {

public boolean testNBTPredicates(String description, ItemStack stack, ItemVariant variant) {
var tested = variant.getNbt();
var cleanString = StringUtils.trim(description);
var cleanString = StringUtils.trim(description).toLowerCase();
var pieces = StringUtils.splitByWholeSeparator(cleanString, null);
var target = pieces[0];
var predicateString = StringUtils.remove(cleanString, target); // We don't want ambiguity when checking for keywords
Expand All @@ -558,10 +558,10 @@ public boolean testNBTPredicates(String description, ItemStack stack, ItemVarian

// A few corrections for ease of use
if (StringUtils.equalsAnyIgnoreCase(target, "durability", "uses"))
target = "Damage";
target = ItemStack.DAMAGE_KEY;

if (StringUtils.equalsAnyIgnoreCase(target, "enchs", "enchants", "enchantment")) {
target = "Enchantments";
target = ItemStack.ENCHANTMENTS_KEY;
}

// Exit early if it just is not there
Expand Down Expand Up @@ -589,7 +589,7 @@ public boolean testNBTPredicates(String description, ItemStack stack, ItemVarian
boolean moreThan = StringUtils.containsIgnoreCase(predicateString, GREATER_THAN_KEYWORD);

// Enchantments are so fucking cursed
if (target.equals("Enchantments") || target.equals("StoredEnchantments")) {
if (target.equals(ItemStack.ENCHANTMENTS_KEY) || target.equals(EnchantedBookItem.STORED_ENCHANTMENTS_KEY)) {
if (testedData.getType() != NbtElement.LIST_TYPE)
return false;

Expand Down Expand Up @@ -638,7 +638,7 @@ public boolean testNBTPredicates(String description, ItemStack stack, ItemVarian
var testedNum = ((AbstractNbtNumber) testedData).doubleValue();

// Special damage keywords - durability is weird and counts up as it decreases
if (target.equals("Damage")) {
if (target.equals(ItemStack.DAMAGE_KEY)) {
if (StringUtils.containsIgnoreCase(predicateString, DAMAGED_KEYWORD)) {
return testedNum > 0;
}
Expand Down Expand Up @@ -686,8 +686,8 @@ public boolean testNBTPredicates(String description, ItemStack stack, ItemVarian
default: {
if (nullSourceFilter)
return true;

// Last resort that will work 50% of the time maybe not realy
// Last resort that will work 50% of the time maybe not really
return sourceData.asString().equals(testedData.asString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ private static boolean hasUniqueReagents(PotionWorkshopBlockEntity potionWorksho
}

private static boolean isBrewingRecipeApplicable(PotionWorkshopBrewingRecipe recipe, ItemStack baseIngredient, PotionWorkshopBlockEntity potionWorkshopBlockEntity) {
return hasUniqueReagents(potionWorkshopBlockEntity) && recipe.recipeData.isApplicableTo(baseIngredient, getPotionModFromReagents(potionWorkshopBlockEntity));
PotionMod potionMod = getPotionModFromReagents(potionWorkshopBlockEntity);
return hasUniqueReagents(potionWorkshopBlockEntity) && recipe.recipeData.isApplicableTo(baseIngredient, potionMod)
&& !(potionMod.incurable && SpectrumStatusEffectTags.cannotBeIncurable(recipe.recipeData.statusEffect()));
}

private static void craftRecipe(PotionWorkshopBlockEntity potionWorkshopBlockEntity, PotionWorkshopCraftingRecipe recipe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void destroy(World world, BlockPos breakerPos, Direction direction) {

float hardness = blockState.getHardness(world, breakingPos);
if (hardness < 0 || hardness > 50) {
world.playSound(null, breakerPos, SoundEvents.BLOCK_IRON_TRAPDOOR_OPEN, SoundCategory.BLOCKS, 0.15f, (2.0f + world.random.nextFloat()));
world.playSound(null, breakerPos, SpectrumSoundEvents.REDSTONE_MECHANISM_BREAK_BLOCK, SoundCategory.BLOCKS, 0.15f, (2.0f + world.random.nextFloat()));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public abstract class DetectorBlock extends Block {
public static final BooleanProperty INVERTED = Properties.INVERTED;
protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D);

protected static final double DETECTION_DIAMETER = 20.0D;

public DetectorBlock(Settings settings) {
super(settings);
this.setDefaultState(((this.stateManager.getDefaultState()).with(POWER, 0)).with(INVERTED, false));
Expand Down Expand Up @@ -87,8 +89,8 @@ public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Ran

abstract int getUpdateFrequencyTicks();

protected Box getBoxWithRadius(BlockPos blockPos, int radius) {
return Box.of(Vec3d.ofCenter(blockPos), radius, radius, radius);
protected Box getDetectionBox(BlockPos pos) {
return Box.of(Vec3d.ofCenter(pos), DETECTION_DIAMETER, DETECTION_DIAMETER, DETECTION_DIAMETER);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public EntityDetectorBlock(Settings settings) {

@Override
protected void updateState(BlockState state, World world, BlockPos pos) {
List<LivingEntity> entities = world.getEntitiesByType(TypeFilter.instanceOf(LivingEntity.class), getBoxWithRadius(pos, 10), LivingEntity::isAlive);
List<LivingEntity> entities = world.getEntitiesByType(TypeFilter.instanceOf(LivingEntity.class), getDetectionBox(pos), LivingEntity::isAlive);

int power = Math.min(entities.size(), 15);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ItemDetectorBlock(Settings settings) {

@Override
protected void updateState(BlockState state, World world, BlockPos pos) {
List<ItemEntity> items = world.getEntitiesByType(EntityType.ITEM, getBoxWithRadius(pos, 10), Entity::isAlive);
List<ItemEntity> items = world.getEntitiesByType(EntityType.ITEM, getDetectionBox(pos), Entity::isAlive);

int power;
if (items.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

@Override
protected void updateState(BlockState state, World world, BlockPos pos) {
List<PlayerEntity> players = world.getEntitiesByType(EntityType.PLAYER, getBoxWithRadius(pos, 10), player -> player.isAlive() && !player.isSpectator());
List<PlayerEntity> players = world.getEntitiesByType(EntityType.PLAYER, getDetectionBox(pos), player -> player.isAlive() && !player.isSpectator());

int power = 0;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.dafuqs.spectrum.blocks.redstone;

import de.dafuqs.spectrum.registries.*;
import net.minecraft.block.*;
import net.minecraft.block.entity.*;
import net.minecraft.entity.player.*;
Expand Down Expand Up @@ -49,7 +50,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
BlockState newModeState = state.cycle(CALCULATION_MODE);
world.setBlockState(pos, newModeState, Block.NOTIFY_ALL);
float pitch = 0.5F + state.get(CALCULATION_MODE).ordinal() * 0.05F;
world.playSound(player, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, pitch);
world.playSound(player, pos, SpectrumSoundEvents.REDSTONE_MECHANISM_TRIGGER, SoundCategory.BLOCKS, 0.3F, pitch);
if (player instanceof ServerPlayerEntity serverPlayerEntity) {
// since this triggers both on server and client side: just send the
// message once, client side is enough, since it is pretty irrelevant on the server
Expand Down
Loading

0 comments on commit 48bd4ed

Please sign in to comment.