Skip to content

Commit

Permalink
fix minor compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadows-of-Fire committed Apr 26, 2024
1 parent cd9c275 commit ab0f736
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
return BedBlock.findStandUpPosition(EntityType.PLAYER, p_36131_, p_36132_, blockstate.getValue(BedBlock.FACING), p_36133_);
} else if (!p_36134_) {
- return Optional.empty();
+ return blockstate.getRespawnPosition(EntityType.PLAYER, p_36131_, p_36132_, p_36133_, null);
+ return blockstate.getRespawnPosition(EntityType.PLAYER, p_36131_, p_36132_, p_36133_);
} else {
boolean flag = block.isPossibleToRespawnInThis(blockstate);
BlockState blockstate1 = p_36131_.getBlockState(p_36132_.above());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,10 @@ default boolean isBed(BlockGetter level, BlockPos pos, LivingEntity sleeper) {
* @param level The current level
* @param pos Block position in level
* @param orientation The angle the entity had when setting the respawn point
* @param entity The entity respawning, often null
* @return The spawn position or the empty optional if respawning here is not possible
*/
default Optional<Vec3> getRespawnPosition(EntityType<?> type, LevelReader level, BlockPos pos, float orientation, @Nullable LivingEntity entity) {
return self().getBlock().getRespawnPosition(self(), type, level, pos, orientation, entity);
default Optional<Vec3> getRespawnPosition(EntityType<?> type, LevelReader level, BlockPos pos, float orientation) {
return self().getBlock().getRespawnPosition(self(), type, level, pos, orientation);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand All @@ -37,7 +36,6 @@
import net.neoforged.testframework.gametest.EmptyTemplate;
import net.neoforged.testframework.gametest.ExtendedGameTestHelper;
import net.neoforged.testframework.registration.RegistrationHelper;
import org.jetbrains.annotations.Nullable;

@ForEachTest(groups = BlockTests.GROUP)
public class BlockTests {
Expand Down Expand Up @@ -83,7 +81,7 @@ protected ItemInteractionResult useItemOn(ItemStack p_316304_, BlockState state,
}

@Override
public Optional<Vec3> getRespawnPosition(BlockState state, EntityType<?> type, LevelReader levelReader, BlockPos pos, float orientation, @Nullable LivingEntity entity) {
public Optional<Vec3> getRespawnPosition(BlockState state, EntityType<?> type, LevelReader levelReader, BlockPos pos, float orientation) {
// have the player respawn a block north to the location of the anchor
return Optional.of(pos.getCenter().add(0, 1, 1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.neoforged.bus.api.Event;
import net.neoforged.neoforge.event.level.BlockEvent;
import net.neoforged.neoforge.event.level.block.CreateFluidSourceEvent;
import net.neoforged.testframework.DynamicTest;
import net.neoforged.testframework.annotation.ForEachTest;
import net.neoforged.testframework.annotation.TestHolder;
Expand All @@ -23,15 +22,15 @@ public class FluidEventTests {
@GameTest
@TestHolder(description = "Tests if the CreateFluidSourceEvent is fired and allows modifying the result")
static void createFluidSourceEvent(final DynamicTest test) {
test.eventListeners().forge().addListener((final BlockEvent.CreateFluidSourceEvent event) -> {
test.eventListeners().forge().addListener((final CreateFluidSourceEvent event) -> {
final BlockState state = event.getState();
final FluidState fluidState = state.getFluidState();
if (fluidState.getType().isSame(Fluids.WATER)) {
event.setResult(Event.Result.DENY);
event.setCanConvert(false);
// Place andesite on top of the sources
event.getLevel().setBlock(event.getPos().above(), Blocks.ANDESITE.defaultBlockState(), 3);
} else if (fluidState.getType().isSame(Fluids.LAVA)) {
event.setResult(Event.Result.ALLOW);
event.setCanConvert(true);
}
});

Expand Down

0 comments on commit ab0f736

Please sign in to comment.