[Feature] New Advancements
This commit is contained in:
parent
ed620a1c57
commit
74faf97a93
10 changed files with 149 additions and 12 deletions
|
@ -3,6 +3,7 @@ package org.betterx.betterend.blocks;
|
|||
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||
import org.betterx.bclib.interfaces.CustomColorProvider;
|
||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.betterend.advancements.BECriteria;
|
||||
import org.betterx.betterend.interfaces.TeleportingEntity;
|
||||
import org.betterx.betterend.registry.EndParticles;
|
||||
import org.betterx.betterend.registry.EndPortals;
|
||||
|
@ -113,7 +114,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
|
|||
ServerLevel destination = isInEnd ? targetWorld : server.getLevel(Level.END);
|
||||
BlockPos exitPos = findExitPos(currentWorld, destination, pos, entity);
|
||||
if (exitPos == null) return;
|
||||
if (entity instanceof ServerPlayer && ((ServerPlayer) entity).isCreative()) {
|
||||
if (entity instanceof ServerPlayer sp && sp.isCreative()) {
|
||||
((ServerPlayer) entity).teleportTo(
|
||||
destination,
|
||||
exitPos.getX() + 0.5,
|
||||
|
@ -122,7 +123,11 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
|
|||
entity.getYRot(),
|
||||
entity.getXRot()
|
||||
);
|
||||
BECriteria.PORTAL_TRAVEL.trigger(sp);
|
||||
} else {
|
||||
if (entity instanceof ServerPlayer sp) {
|
||||
BECriteria.PORTAL_TRAVEL.trigger(sp);
|
||||
}
|
||||
((TeleportingEntity) entity).be_setExitPos(exitPos);
|
||||
Optional<Entity> teleported = Optional.ofNullable(entity.changeDimension(destination));
|
||||
teleported.ifPresent(Entity::setPortalCooldown);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class EternalPedestal extends PedestalBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkRitual(Level world, BlockPos pos) {
|
||||
public void checkRitual(Level world, Player player, BlockPos pos) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof EternalPedestalEntity) {
|
||||
EternalPedestalEntity pedestal = (EternalPedestalEntity) blockEntity;
|
||||
|
@ -64,10 +64,10 @@ public class EternalPedestal extends PedestalBlock {
|
|||
if (EndPortals.isAvailableItem(id)) {
|
||||
world.setBlockAndUpdate(pos, updatedState.setValue(ACTIVATED, true).setValue(HAS_LIGHT, true));
|
||||
if (pedestal.hasRitual()) {
|
||||
pedestal.getRitual().checkStructure();
|
||||
pedestal.getRitual().checkStructure(player);
|
||||
} else {
|
||||
EternalRitual ritual = new EternalRitual(world, pos);
|
||||
ritual.checkStructure();
|
||||
ritual.checkStructure(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.betterend.blocks.entities.InfusionPedestalEntity;
|
|||
import org.betterx.betterend.rituals.InfusionRitual;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -30,7 +31,7 @@ public class InfusionPedestal extends PedestalBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkRitual(Level world, BlockPos pos) {
|
||||
public void checkRitual(Level world, Player player, BlockPos pos) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof InfusionPedestalEntity) {
|
||||
InfusionPedestalEntity pedestal = (InfusionPedestalEntity) blockEntity;
|
||||
|
|
|
@ -118,14 +118,14 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
|||
if (itemStack.isEmpty()) return InteractionResult.CONSUME;
|
||||
pedestal.setItem(0, itemStack);
|
||||
level.blockEntityChanged(pos);
|
||||
checkRitual(level, pos);
|
||||
checkRitual(level, player, pos);
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
} else {
|
||||
ItemStack itemStack = pedestal.getItem(0);
|
||||
if (player.addItem(itemStack)) {
|
||||
pedestal.removeItemNoUpdate(0);
|
||||
level.blockEntityChanged(pos);
|
||||
checkRitual(level, pos);
|
||||
checkRitual(level, player, pos);
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
return InteractionResult.FAIL;
|
||||
|
@ -153,13 +153,13 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
|||
}
|
||||
}
|
||||
|
||||
public void checkRitual(Level world, BlockPos pos) {
|
||||
public void checkRitual(Level world, Player player, BlockPos pos) {
|
||||
MutableBlockPos posMutable = new MutableBlockPos();
|
||||
for (Point point : InfusionRitual.getMap()) {
|
||||
posMutable.set(pos).move(point.x, 0, point.y);
|
||||
BlockState state = world.getBlockState(posMutable);
|
||||
if (state.getBlock() instanceof InfusionPedestal) {
|
||||
((InfusionPedestal) state.getBlock()).checkRitual(world, posMutable);
|
||||
((InfusionPedestal) state.getBlock()).checkRitual(world, player, posMutable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue