70 lines
2.7 KiB
Java
70 lines
2.7 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.core.particles.ParticleOptions;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import java.util.Random;
|
|
import net.minecraft.world.level.dimension.DimensionType;
|
|
import net.minecraft.world.phys.shapes.BooleanOp;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
public class EndPortalBlock extends BaseEntityBlock {
|
|
protected static final VoxelShape SHAPE;
|
|
|
|
protected EndPortalBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public BlockEntity newBlockEntity(final BlockGetter bjd) {
|
|
return new TheEndPortalBlockEntity();
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return EndPortalBlock.SHAPE;
|
|
}
|
|
|
|
@Override
|
|
public void entityInside(final BlockState byg, final Level bjt, final BlockPos fk, final Entity akn) {
|
|
if (!bjt.isClientSide && !akn.isPassenger() && !akn.isVehicle() && akn.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(akn.getBoundingBox().move(-fk.getX(), -fk.getY(), -fk.getZ())), byg.getShape(bjt, fk), BooleanOp.AND)) {
|
|
akn.changeDimension((bjt.dimension.getType() == DimensionType.THE_END) ? DimensionType.OVERWORLD : DimensionType.THE_END);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void animateTick(final BlockState byg, final Level bjt, final BlockPos fk, final Random random) {
|
|
final double double6 = fk.getX() + (double)random.nextFloat();
|
|
final double double7 = fk.getY() + 0.8;
|
|
final double double8 = fk.getZ() + (double)random.nextFloat();
|
|
final double double9 = 0.0;
|
|
final double double10 = 0.0;
|
|
final double double11 = 0.0;
|
|
bjt.addParticle(ParticleTypes.SMOKE, double6, double7, double8, 0.0, 0.0, 0.0);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack getCloneItemStack(final BlockGetter bjd, final BlockPos fk, final BlockState byg) {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
@Override
|
|
public boolean canBeReplaced(final BlockState byg, final Fluid cof) {
|
|
return false;
|
|
}
|
|
|
|
static {
|
|
SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
|
|
}
|
|
}
|