Skip to content

Commit

Permalink
Merge branch 'master' into 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Oct 30, 2024
2 parents f98fb76 + 829f5f3 commit ffc4d04
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 71 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
}

plugins {
id("fabric-loom") version("1.7.+")
id("fabric-loom") version("+")
id("org.quiltmc.gradle.licenser") version("+")
id("org.ajoberstar.grgit") version("+")
id("com.modrinth.minotaur") version("+")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ archives_base_name = TrailierTales
# Dependencies
fabric_api_version=0.106.0+1.21.2
frozenlib_version=1.9-mc1.21.2
wilderwild_version=3.0.1-mc1.21.2
wilderwild_version=3.0.2-mc1.21.2

# External Mods
modmenu_version=11.0.2
Expand Down
56 changes: 13 additions & 43 deletions src/main/java/net/frozenblock/trailiertales/block/CoffinBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.ScheduledTickAccess;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Spawner;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DoubleBlockCombiner;
Expand Down Expand Up @@ -102,7 +104,7 @@ public static Direction getCoffinOrientation(@NotNull BlockGetter level, BlockPo
BlockState neighborState,
RandomSource random
) {
if (direction == getNeighbourDirection(state.getValue(PART), state.getValue(FACING))) {
if (direction == getConnectedDirection(state.getValue(PART), state.getValue(FACING))) {
boolean isThisFoot = state.getValue(PART) == CoffinPart.FOOT;
return neighborState.is(this) && neighborState.getValue(PART) != state.getValue(PART)
? isThisFoot ? state : state.setValue(STATE, neighborState.getValue(STATE))
Expand All @@ -112,16 +114,20 @@ public static Direction getCoffinOrientation(@NotNull BlockGetter level, BlockPo
}
}

private static Direction getNeighbourDirection(CoffinPart part, Direction direction) {
private static Direction getConnectedDirection(CoffinPart part, Direction direction) {
return part == CoffinPart.FOOT ? direction : direction.getOpposite();
}

public static Direction getConnectedDirection(@NotNull BlockState state) {
return getConnectedDirection(state.getValue(PART), state.getValue(FACING));
}

@Override
public @NotNull BlockState playerWillDestroy(@NotNull Level level, BlockPos pos, BlockState state, Player player) {
if (!level.isClientSide && player.isCreative()) {
CoffinPart coffinPart = state.getValue(PART);
if (coffinPart == CoffinPart.FOOT) {
BlockPos blockPos = pos.relative(getNeighbourDirection(coffinPart, state.getValue(FACING)));
BlockPos blockPos = pos.relative(getConnectedDirection(coffinPart, state.getValue(FACING)));
BlockState blockState = level.getBlockState(blockPos);
if (blockState.is(this) && blockState.getValue(PART) == CoffinPart.HEAD) {
level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 35);
Expand Down Expand Up @@ -156,11 +162,6 @@ public BlockState getStateForPlacement(@NotNull BlockPlaceContext context) {
};
}

public static Direction getConnectedDirection(@NotNull BlockState state) {
Direction direction = state.getValue(FACING);
return state.getValue(PART) == CoffinPart.HEAD ? direction.getOpposite() : direction;
}

public static DoubleBlockCombiner.BlockType getBlockType(@NotNull BlockState state) {
CoffinPart coffinPart = state.getValue(PART);
return coffinPart == CoffinPart.HEAD ? DoubleBlockCombiner.BlockType.FIRST : DoubleBlockCombiner.BlockType.SECOND;
Expand Down Expand Up @@ -207,41 +208,18 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
return level instanceof ServerLevel serverLevel
? createTickerHelper(
? BaseEntityBlock.createTickerHelper(
blockEntityType,
TTBlockEntityTypes.COFFIN,
(unusedWorld, pos, statex, coffin) -> coffin.getCoffinSpawner()
.tickServer(serverLevel, pos, statex, statex.getValue(PART), statex.getOptionalValue(BlockStateProperties.OMINOUS).orElse(false)))
: createTickerHelper(
: BaseEntityBlock.createTickerHelper(
blockEntityType,
TTBlockEntityTypes.COFFIN,
(world, pos, statex, coffin) -> coffin
.tickClient(world, pos, statex.getValue(PART), statex.getOptionalValue(BlockStateProperties.OMINOUS).orElse(false)));
}

public static boolean isCoffinBlockedAt(Direction direction, @NotNull BlockGetter level, BlockPos pos) {
BlockState state = level.getBlockState(pos);
direction = state.getValue(PART) == CoffinPart.HEAD ? direction.getOpposite() : direction;
return isCoffinHalfBlockedAt(level, pos) || isCoffinHalfBlockedAt(level, pos.relative(direction));
}

private static boolean isCoffinHalfBlockedAt(@NotNull BlockGetter level, @NotNull BlockPos pos) {
BlockPos blockPos = pos.above();
return level.getBlockState(blockPos).isRedstoneConductor(level, blockPos);
}

private static int getLightLevel(@NotNull Level level, @NotNull BlockPos pos) {
BlockPos.MutableBlockPos mutableBlockPos = pos.mutable();
int finalLight = 0;
for (Direction direction : Direction.values()) {
mutableBlockPos.move(direction);
int newLight = level.getBrightness(LightLayer.BLOCK, mutableBlockPos);
finalLight = Math.max(finalLight, newLight);
mutableBlockPos.move(direction, -1);
}
return finalLight;
}

@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext tooltipContext, List<Component> tooltip, TooltipFlag options) {
super.appendHoverText(stack, tooltipContext, tooltip, options);
Expand Down Expand Up @@ -283,14 +261,6 @@ public static void onCoffinUntrack(ServerLevel level, @Nullable Entity entity, @
}
}

@SuppressWarnings({"unchecked", "SameParameterValue"})
@Nullable
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(
BlockEntityType<A> serverType, BlockEntityType<E> clientType, BlockEntityTicker<? super E> ticker
) {
return clientType == serverType ? (BlockEntityTicker<A>) ticker : null;
}

public static void spawnParticlesFrom(
@NotNull ServerLevel world,
ParticleOptions particleOptions,
Expand All @@ -307,8 +277,8 @@ public static void spawnParticlesFrom(
double stepZ = coffinOrientation.getStepZ();
double relativeX = isOppositeX ? 0D : stepX == 0D ? 0.5D : stepX;
double relativeZ = isOppositeZ ? 0D : stepZ == 0D ? 0.5D : stepZ;
double xOffset = Math.abs(stepX * spread);
double zOffset = Math.abs(stepZ * spread);
double xOffset = Math.max(0.5D, Math.abs(stepX)) * spread;
double zOffset = Math.max(0.5D, Math.abs(stepZ)) * spread;
world.sendParticles(
particleOptions,
pos.getX() + relativeX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import net.frozenblock.trailiertales.block.impl.CoffinPart;
import net.frozenblock.trailiertales.block.impl.TTBlockStateProperties;
import net.frozenblock.trailiertales.registry.TTBlockEntityTypes;
import net.frozenblock.trailiertales.registry.TTParticleTypes;
import net.frozenblock.trailiertales.registry.TTSounds;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
Expand Down Expand Up @@ -85,10 +87,13 @@ public void tickClient(Level world, BlockPos pos, CoffinPart part, boolean omino
float lidIncrement = this.coffinSpawner.isAttemptingToSpawnMob() ? 0.0155F : -0.03F;
this.openProgress = Mth.clamp(this.openProgress + lidIncrement, 0F, 1F);

Direction facing = CoffinBlock.getCoffinOrientation(world, pos);
if (facing != null && world.getBlockEntity(pos.relative(facing)) instanceof CoffinBlockEntity coffinBlockEntity) {
coffinBlockEntity.previousOpenProgress = this.previousOpenProgress;
coffinBlockEntity.openProgress = this.openProgress;
Direction connectedDirection = CoffinBlock.getConnectedDirection(this.getBlockState());
if (connectedDirection != null) {
BlockPos connectedPos = pos.relative(connectedDirection);
if (world.isLoaded(connectedPos) && world.getBlockEntity(connectedPos) instanceof CoffinBlockEntity coffinBlockEntity) {
coffinBlockEntity.previousOpenProgress = this.previousOpenProgress;
coffinBlockEntity.openProgress = this.openProgress;
}
}
}

Expand Down Expand Up @@ -119,6 +124,31 @@ public void setEntityId(EntityType<?> entityType, RandomSource random) {
}
}
coffinSpawner.getData().setEntityId(entityType, this.level, random, pos);

Direction coffinOrientation = CoffinBlock.getCoffinOrientation(this.level, pos);
if (coffinOrientation != null && this.level instanceof ServerLevel serverLevel) {
BlockPos finalPos = pos;
CoffinSpawnerState.ACTIVE.getParticleOptionsForState().ifPresent(particleOptions ->
CoffinBlock.spawnParticlesFrom(
serverLevel,
particleOptions,
level.random.nextInt(1, 5),
0.5D,
coffinOrientation,
finalPos,
0.5D
)
);
CoffinBlock.spawnParticlesFrom(
serverLevel,
TTParticleTypes.COFFIN_SOUL_ENTER,
level.random.nextInt(1, 2),
0D,
coffinOrientation,
finalPos,
0.5D
);
}
this.setChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,17 @@ public void tickServer(ServerLevel level, BlockPos pos, BlockState state, Coffin
}
}

Direction connectedDirection = CoffinBlock.getConnectedDirection(state);
if (connectedDirection != null) {
BlockPos connectedPos = pos.relative(connectedDirection);
if (world.isLoaded(connectedPos)) {
if (coffinOrientation == null || !(world.getBlockEntity(connectedPos) instanceof CoffinBlockEntity)) {
world.destroyBlock(pos, false);
return;
}
}
}

this.data.currentMobs.removeIf(uiid -> {
Entity entity = level.getEntity(uiid);
boolean shouldUntrack = shouldMobBeUntracked(level, pos, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ private static CoffinSpawnerState activeTickAndGetNext(
spawner.spawnApparition(level, pos);
}

if (!coffinSpawnerData.isPowerCooldownFinished(level) && coffinSpawnerData.power >= coffinSpawnerConfig.powerForNextLevel()) {
if (!coffinSpawnerState.finalWave && !coffinSpawnerData.isPowerCooldownFinished(level) && coffinSpawnerData.power >= coffinSpawnerConfig.powerForNextLevel()) {
coffinSpawnerData.powerCooldownEndsAt = level.getGameTime() + (long)spawner.getPowerCooldownLength();
coffinSpawnerData.power = coffinSpawnerState == AGGRESSIVE ? spawner.getAggressiveConfig().powerForNextLevel() : coffinSpawnerData.power;
coffinSpawnerData.power = coffinSpawnerState == AGGRESSIVE ? spawner.getConfig().powerForNextLevel() : coffinSpawnerData.power;
level.playSound(null, pos, TTSounds.COFFIN_INCREASE_POWER, SoundSource.BLOCKS, 0.5F, 0.9F + (level.random.nextFloat() * 0.2F));
return coffinSpawnerState.getNextPowerState();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public void emitParticles(ServerLevel level, BlockPos pos, Direction coffinOrien
0.5D,
coffinOrientation,
pos,
1D
0.5D
);
}
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 21 additions & 19 deletions src/main/resources/credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,7 @@ wigglewoggle - Builder
- Generic, Savanna, Desert, and Jungle ruins

Soro335
- Came up with Badlands Fort designs

Voxelotl
- Texture Artist:
- Suspicious Clay
- Cracked and Chiseled Purpur Blocks
- Mossy Cobbled Deepslate
- Mossy Deepslate Bricks
- Mossy Deepslate Tiles
- Bloom Pottery Sherd/Pattern
- Bullseye Pottery Sherd/Pattern
- Crescent Pottery Sherd/Pattern
- Wither Pottery Sherd/Pattern
- Coffin
- Undead Armor Trim
- Surveyor
- Apparition
- All Boat Banner Posts
- Siege Omen icon and particle texture
- Came up with initial Badlands Fort designs

Zhen
- Texture Artist:
Expand Down Expand Up @@ -75,6 +57,26 @@ Zhen
- Came up with the functionality of the Reaping enchantment
- Made the Fausse Vie music disc

Voxelotl
- Texture Artist:
- Suspicious Clay
- Cracked and Chiseled Purpur Blocks
- Mossy Cobbled Deepslate
- Mossy Deepslate Bricks
- Mossy Deepslate Tiles
- Bloom Pottery Sherd/Pattern
- Bullseye Pottery Sherd/Pattern
- Crescent Pottery Sherd/Pattern
- Wither Pottery Sherd/Pattern
- Coffin
- Undead Armor Trim
- Surveyor
- Apparition
- All Boat Banner Posts
- Siege Omen icon and particle texture
- Fixed the Chiseled Andesite texture
- Fixed the Chiseled Diorite texture

Stella/Osmiooo
- Implemented the new Andesite, Diorite, and Granite blocks
- Implemented the Wither Pottery Sherd
Expand Down

0 comments on commit ffc4d04

Please sign in to comment.