Skip to content

Commit

Permalink
Merge branch '1.21.2' into 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Dec 7, 2024
2 parents d9c63c3 + 1c765e7 commit 8f49af5
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 251 deletions.
13 changes: 4 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ Thank you!
Put the changelog BELOW the dashes. ANYTHING ABOVE IS IGNORED
hi
-----------------
- Revamped the placement of Cypress Wetlands, being placed more logically within the world.
- Cypress Wetlands now ease the border between Jungle and Swamp biomes.
- Mangrove Swamps are no longer small and rare.
- Decreased the size of Maple Forests in an attempt to restore the size of Plains biomes.
- Fixed the wrong config being used for Windswept Savanna placement modification... again.
- Fixed Ostrich rendering being somewhat broken on 1.21.2+.
- Removed an unused damage type for a certain removed item.
- Cleaned up a few mixins.
- Added a Brazilian Portuguese translation, thanks to demorogabrtz! ([#440](https://github.com/FrozenBlock/WilderWild/pull/440))
- Fixed non-stone Chests bubbling upon being placed into a Double-Chest underwater.
- Added a config to control whether Chests can bubble.
- Cleaned up and optimized more mixins.
- Fixed a crash with VMP.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ modrinth {

val github by tasks.register("github") {
dependsOn(remapJar)
dependsOn(sourcesJar)
dependsOn(javadocJar)

val env = System.getenv()
val token = env["GITHUB_TOKEN"]
val repoVar = env["GITHUB_REPOSITORY"]
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

# Mod Properties
mod_id = wilderwild
mod_version = 3.0.10
mod_version = 3.0.11
# protocol version must be changed after each update with dual env changes
protocol_version = 11
maven_group = net.frozenblock
archives_base_name = WilderWild

# Dependencies
fabric_api_version=0.110.5+1.21.4
frozenlib_version=1.9.5-mc1.21.4
frozenlib_version=1.9.6-mc1.21.4

# External Mods
modmenu_version=11.0.2
Expand Down
114 changes: 38 additions & 76 deletions src/main/java/net/frozenblock/wilderwild/block/StoneChestBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.function.Supplier;
import net.frozenblock.wilderwild.block.entity.StoneChestBlockEntity;
import net.frozenblock.wilderwild.block.entity.impl.ChestBlockEntityInterface;
import net.frozenblock.wilderwild.block.impl.ChestUtil;
import net.frozenblock.wilderwild.entity.Jellyfish;
import net.frozenblock.wilderwild.registry.WWBlockEntityTypes;
import net.frozenblock.wilderwild.registry.WWBlockStateProperties;
Expand Down Expand Up @@ -193,23 +194,6 @@ public static void spawnBreakParticles(@NotNull Level level, @NotNull ItemStack
}
}

@Nullable
public static StoneChestBlockEntity getOtherChest(@NotNull LevelReader level, @NotNull BlockPos pos, @NotNull BlockState state) {
BlockPos.MutableBlockPos mutableBlockPos = pos.mutable();
ChestType chestType = state.getValue(ChestBlock.TYPE);
if (chestType == ChestType.RIGHT) {
mutableBlockPos.move(ChestBlock.getConnectedDirection(state));
} else if (chestType == ChestType.LEFT) {
mutableBlockPos.move(ChestBlock.getConnectedDirection(state));
} else {
return null;
}
if (level.getBlockEntity(mutableBlockPos) instanceof StoneChestBlockEntity chest) {
return chest;
}
return null;
}

@NotNull
@Override
public MapCodec<? extends StoneChestBlock> codec() {
Expand Down Expand Up @@ -256,11 +240,14 @@ public InteractionResult useWithoutItem(@NotNull BlockState state, @NotNull Leve
level.gameEvent(player, GameEvent.CONTAINER_OPEN, pos);
}
}
StoneChestBlockEntity otherChest = getOtherChest(level, pos, state);
if (otherChest != null) {
((ChestBlockEntityInterface) stoneChest).wilderWild$syncBubble(stoneChest, otherChest);
}
stoneChest.syncLidValuesAndUpdate(otherChest);

Optional<StoneChestBlockEntity> possibleCoupledStoneChest = ChestUtil.getCoupledStoneChestBlockEntity(level, pos, state);
possibleCoupledStoneChest.ifPresent(otherStoneChest -> {
if (otherStoneChest instanceof ChestBlockEntityInterface chestBlockEntityInterface) {
chestBlockEntityInterface.wilderWild$syncBubble(stoneChest, otherStoneChest);
}
});
stoneChest.syncLidValuesAndUpdate(possibleCoupledStoneChest.orElse(null));
}
return InteractionResult.CONSUME;
}
Expand Down Expand Up @@ -306,59 +293,29 @@ public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> get
BlockState neighborState,
RandomSource randomSource
) {
if (!blockState.hasProperty(WATERLOGGED)) return blockState;
if (blockState.getValue(WATERLOGGED)) {
scheduledTickAccess.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelReader));
}

BlockState retState = blockState;
if (neighborState.is(this) && direction.getAxis().isHorizontal()) {
//if (neighborState.get(ANCIENT) == state.get(ANCIENT)) {
ChestType chestType = neighborState.getValue(TYPE);
if (blockState.getValue(TYPE) == ChestType.SINGLE
&& chestType != ChestType.SINGLE
&& blockState.getValue(FACING) == neighborState.getValue(FACING)
&& blockState.getValue(ANCIENT) == neighborState.getValue(ANCIENT)
&& ChestBlock.getConnectedDirection(neighborState) == direction.getOpposite()
) {
BlockState retState = blockState.setValue(TYPE, chestType.getOpposite());
updateBubbles(blockState, retState, levelReader, blockPos);
return retState;
retState = blockState.setValue(TYPE, chestType.getOpposite());
}
//}
} else if (ChestBlock.getConnectedDirection(blockState) == direction) {
BlockState retState = blockState.setValue(TYPE, ChestType.SINGLE);
updateBubbles(blockState, retState, levelReader, blockPos);
return retState;
retState = blockState.setValue(TYPE, ChestType.SINGLE);
} else {
retState = super.updateShape(blockState, levelReader, scheduledTickAccess, blockPos, direction, neighborPos, neighborState, randomSource);
}
BlockState retState = super.updateShape(blockState, levelReader, scheduledTickAccess, blockPos, direction, neighborPos, neighborState, randomSource);
updateBubbles(blockState, retState, levelReader, blockPos);
return retState;
}

public void updateBubbles(@NotNull BlockState oldState, @NotNull BlockState state, @NotNull LevelReader level, @NotNull BlockPos currentPos) {
if (level.getBlockEntity(currentPos) instanceof StoneChestBlockEntity chest) {
StoneChestBlockEntity otherChest = getOtherChest(level, currentPos, state);
if (otherChest != null) {
BlockState otherState = level.getBlockState(otherChest.getBlockPos());
boolean wasLogged = oldState.getValue(BlockStateProperties.WATERLOGGED);
if (wasLogged != state.getValue(BlockStateProperties.WATERLOGGED) && wasLogged) {
if (!otherState.getValue(BlockStateProperties.WATERLOGGED)) {
((ChestBlockEntityInterface) chest).wilderWild$setCanBubble(true);
((ChestBlockEntityInterface) otherChest).wilderWild$setCanBubble(true);
} else if (!((ChestBlockEntityInterface) otherChest).wilderWild$getCanBubble()) {
((ChestBlockEntityInterface) chest).wilderWild$setCanBubble(false);
((ChestBlockEntityInterface) otherChest).wilderWild$setCanBubble(false);
}
}
} else {
boolean wasLogged = oldState.getValue(BlockStateProperties.WATERLOGGED);
if (wasLogged != state.getValue(BlockStateProperties.WATERLOGGED) && wasLogged) {
((ChestBlockEntityInterface) chest).wilderWild$setCanBubble(true);
}
}
if (otherChest != null) {
((ChestBlockEntityInterface) chest).wilderWild$syncBubble(chest, otherChest);
}
}
ChestUtil.updateBubbles(blockState, retState, levelReader, blockPos);
return retState;
}

@Override
Expand All @@ -382,14 +339,19 @@ public BlockState getStateForPlacement(@NotNull BlockPlaceContext ctx) {
chestType = ChestType.RIGHT;
}
}

BlockState retState = this.defaultBlockState().setValue(FACING, direction).setValue(TYPE, chestType).setValue(WATERLOGGED, fluidState.getType() == Fluids.WATER);
StoneChestBlockEntity otherChest = getOtherChest(level, pos, retState);
if (otherChest != null) {
if (level.getBlockEntity(pos) instanceof StoneChestBlockEntity chest) {
((ChestBlockEntityInterface) chest).wilderWild$setCanBubble(((ChestBlockEntityInterface) otherChest).wilderWild$getCanBubble());
((ChestBlockEntityInterface) chest).wilderWild$syncBubble(chest, otherChest);

ChestUtil.getCoupledStoneChestBlockEntity(level, pos, retState).ifPresent(coupledStoneChest -> {
if (
coupledStoneChest instanceof ChestBlockEntityInterface coupledStoneChestInterface
&& level.getBlockEntity(pos) instanceof StoneChestBlockEntity chest
&& chest instanceof ChestBlockEntityInterface chestInterface
) {
chestInterface.wilderWild$setCanBubble(coupledStoneChestInterface.wilderWild$getCanBubble());
chestInterface.wilderWild$syncBubble(chest, coupledStoneChest);
}
}
});
return retState;
}

Expand All @@ -401,16 +363,17 @@ private Direction candidatePartnerFacing(@NotNull BlockPlaceContext ctx, @NotNul

@Override
public void onRemove(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState newState, boolean moved) {
if (state.is(newState.getBlock())) {
return;
}
if (state.is(newState.getBlock())) return;

if (!level.isClientSide) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof StoneChestBlockEntity stoneChestBlock) {
((ChestBlockEntityInterface) stoneChestBlock).wilderWild$bubbleBurst(state);
if (blockEntity instanceof StoneChestBlockEntity stoneChest) {
if (stoneChest instanceof ChestBlockEntityInterface stoneChestInterface) {
stoneChestInterface.wilderWild$bubbleBurst(state);
}

stoneChestBlock.unpackLootTable(null);
ArrayList<ItemStack> ancientItems = stoneChestBlock.ancientItems();
stoneChest.unpackLootTable(null);
ArrayList<ItemStack> ancientItems = stoneChest.ancientItems();
if (!ancientItems.isEmpty()) {
level.playSound(null, pos, WWSounds.BLOCK_STONE_CHEST_ITEM_CRUMBLE, SoundSource.BLOCKS, 0.4F, 0.9F + (level.random.nextFloat() / 10F));
for (ItemStack taunt : ancientItems) {
Expand All @@ -420,7 +383,7 @@ public void onRemove(@NotNull BlockState state, @NotNull Level level, @NotNull B
}
}
RandomSource random = level.getRandom();
for (ItemStack item : stoneChestBlock.nonAncientItems()) {
for (ItemStack item : stoneChest.nonAncientItems()) {
double d = EntityType.ITEM.getWidth();
double e = 1D - d;
double f = d / 2D;
Expand Down Expand Up @@ -452,8 +415,7 @@ public boolean hasAnalogOutputSignal(@NotNull BlockState state) {

@Override
public int getAnalogOutputSignal(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof StoneChestBlockEntity stoneChestBlockEntity) {
if (level.getBlockEntity(pos) instanceof StoneChestBlockEntity stoneChestBlockEntity) {
return stoneChestBlockEntity.getComparatorOutput();
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.ArrayList;
import java.util.Objects;
import net.frozenblock.wilderwild.block.StoneChestBlock;
import net.frozenblock.wilderwild.block.impl.ChestUtil;
import net.frozenblock.wilderwild.config.WWBlockConfig;
import net.frozenblock.wilderwild.networking.packet.WWStoneChestLidPacket;
import net.frozenblock.wilderwild.registry.WWBlockEntityTypes;
Expand Down Expand Up @@ -101,35 +101,36 @@ public StoneChestBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blo
}

public static void serverStoneTick(@NotNull Level level, BlockPos pos, @NotNull BlockState state, @NotNull StoneChestBlockEntity stoneChest) {
ServerLevel serverLevel = (ServerLevel) level;
StoneChestBlockEntity otherChest = StoneChestBlock.getOtherChest(serverLevel, pos, state);
long gameTime = level.getGameTime();
if (gameTime != stoneChest.updateTime) {
if (stoneChest.cooldownTicks > 0) {
--stoneChest.cooldownTicks;
}
stoneChest.prevOpenProgress = stoneChest.openProgress;
if (stoneChest.stillLidTicks > 0) {
stoneChest.stillLidTicks -= 1;
} else if (stoneChest.openProgress > 0F) {
level.updateNeighbourForOutputSignal(pos, stoneChest.getBlockState().getBlock());
serverLevel.gameEvent(null, GameEvent.CONTAINER_CLOSE, pos);
stoneChest.openProgress = Math.max(0F, stoneChest.openProgress - LID_SLAM_INTERVAL);
if (!stoneChest.closing) {
stoneChest.closing = true;
playSound(serverLevel, pos, state, WWSounds.BLOCK_STONE_CHEST_CLOSE_START, WWSounds.BLOCK_STONE_CHEST_CLOSE_START_UNDERWATER, 0.3F);
if (level instanceof ServerLevel serverLevel) {
StoneChestBlockEntity coupledStoneChest = ChestUtil.getCoupledStoneChestBlockEntity(serverLevel, pos, state).orElse(null);
long gameTime = level.getGameTime();
if (gameTime != stoneChest.updateTime) {
if (stoneChest.cooldownTicks > 0) {
--stoneChest.cooldownTicks;
}
if (stoneChest.openProgress <= 0F) {
stoneChest.onLidSlam(serverLevel, pos, state, otherChest);
stoneChest.prevOpenProgress = stoneChest.openProgress;
if (stoneChest.stillLidTicks > 0) {
stoneChest.stillLidTicks -= 1;
} else if (stoneChest.openProgress > 0F) {
level.updateNeighbourForOutputSignal(pos, stoneChest.getBlockState().getBlock());
serverLevel.gameEvent(null, GameEvent.CONTAINER_CLOSE, pos);
stoneChest.openProgress = Math.max(0F, stoneChest.openProgress - LID_SLAM_INTERVAL);
if (!stoneChest.closing) {
stoneChest.closing = true;
playSound(serverLevel, pos, state, WWSounds.BLOCK_STONE_CHEST_CLOSE_START, WWSounds.BLOCK_STONE_CHEST_CLOSE_START_UNDERWATER, 0.3F);
}
if (stoneChest.openProgress <= 0F) {
stoneChest.onLidSlam(serverLevel, pos, state, coupledStoneChest);
}
}
stoneChest.updateTime = gameTime;
stoneChest.syncLidValuesAndUpdate(coupledStoneChest);
}
stoneChest.updateTime = gameTime;
stoneChest.syncLidValuesAndUpdate(otherChest);
}
}

public static void clientStoneTick(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull StoneChestBlockEntity stoneChest) {
StoneChestBlockEntity otherChest = StoneChestBlock.getOtherChest(level, pos, state);
StoneChestBlockEntity coupledStoneChest = ChestUtil.getCoupledStoneChestBlockEntity(level, pos, state).orElse(null);
long gameTime = level.getGameTime();
if (gameTime != stoneChest.updateTime) {
stoneChest.prevOpenProgress = stoneChest.openProgress;
Expand All @@ -142,15 +143,22 @@ public static void clientStoneTick(@NotNull Level level, @NotNull BlockPos pos,
stoneChest.closing = true;
stoneChest.openProgress = Math.max(0F, stoneChest.openProgress - LID_SLAM_INTERVAL);
if (stoneChest.openProgress <= 0F) {
stoneChest.onLidSlam(level, pos, state, otherChest);
stoneChest.onLidSlam(level, pos, state, coupledStoneChest);
}
}
stoneChest.updateTime = gameTime;
stoneChest.syncLidValuesAndUpdate(otherChest);
stoneChest.syncLidValuesAndUpdate(coupledStoneChest);
}
}

public static void playSound(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull SoundEvent soundEvent, @NotNull SoundEvent waterloggedSoundEvent, float volume) {
public static void playSound(
@NotNull Level level,
@NotNull BlockPos pos,
@NotNull BlockState state,
@NotNull SoundEvent soundEvent,
@NotNull SoundEvent waterloggedSoundEvent,
float volume
) {
ChestType chestType = state.getValue(ChestBlock.TYPE);
double x = pos.getX() + 0.5D;
double y = pos.getY() + 0.5D;
Expand All @@ -164,7 +172,16 @@ public static void playSound(@NotNull Level level, @NotNull BlockPos pos, @NotNu
x -= direction.getStepX() * 0.5D;
z -= direction.getStepZ() * 0.5D;
}
level.playSound(null, x, y, z, state.getValue(BlockStateProperties.WATERLOGGED) ? waterloggedSoundEvent : soundEvent, SoundSource.BLOCKS, volume, level.random.nextFloat() * 0.18F + 0.9F);
level.playSound(
null,
x,
y,
z,
state.getValue(BlockStateProperties.WATERLOGGED) && WWBlockConfig.get().chestBubbling ? waterloggedSoundEvent : soundEvent,
SoundSource.BLOCKS,
volume,
level.random.nextFloat() * 0.18F + 0.9F
);
}

@Override
Expand Down
Loading

0 comments on commit 8f49af5

Please sign in to comment.