Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ repositories {
maven {
url = "https://code.redspace.io/snapshots"
}
exclusiveContent { // Sable
forRepository {
maven {
url = "https://maven.ryanhcode.dev/releases"
name = "RyanHCode Maven"
}
}
filter {
includeGroup("dev.ryanhcode.sable")
includeGroup("dev.ryanhcode.sable-companion")
}
}
}

jarJar.enable()
Expand Down Expand Up @@ -109,6 +121,12 @@ dependencies {

// runtimeOnly "curse.maven:spark-361579:6225208"

// SABLE ********************************************************************************************************
jarJar(api("dev.ryanhcode.sable-companion:sable-companion-common-${project.minecraft_version}:[${project.sable_companion_version},)")) {
version {
prefer project.sable_companion_version
}
}

// PATCHOULI **************************************************************************************************
// localRuntime "vazkii.patchouli:Patchouli:${patchouli_version}-NEOFORGE"
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minecraft_version=1.21.1
minecraft_version_range=[1.21.1,1.21.2)

# Forge
neo_version=21.1.200
neo_version=21.1.219
neo_version_range=[21.0.0-beta,)
loader_version_range=[4,)

Expand Down Expand Up @@ -40,6 +40,7 @@ player_animator_version=2.0.1+1.21.1
patchouli_version=1.21-87
curios_version=9.5.1
irons_lib_version=1.21.1-1.0.2-SNAPSHOT
sable_companion_version=1.6.0

# General
gson_version=2.10.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.redspace.ironsspellbooks.block.portal_frame;

import com.mojang.serialization.MapCodec;
import dev.ryanhcode.sable.companion.SableCompanion;
import io.redspace.ironsspellbooks.config.ServerConfigs;
import io.redspace.ironsspellbooks.registries.BlockRegistry;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -32,12 +33,12 @@
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.*;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3d;

public class PortalFrameBlock extends BaseEntityBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
Expand Down Expand Up @@ -149,7 +150,15 @@ protected VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, Bl
protected void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity pEntity) {
if (!pEntity.level.isClientSide) {
VoxelShape voxelshape = pState.getShape(pLevel, pPos, CollisionContext.of(pEntity));
VoxelShape voxelshape1 = voxelshape.move((double) pPos.getX(), (double) pPos.getY(), (double) pPos.getZ());
Vector3d movePos = SableCompanion.INSTANCE.projectOutOfSubLevel(pLevel, new Vector3d(pPos.getX(), pPos.getY(), pPos.getZ()));
var sublevel = SableCompanion.INSTANCE.getContaining(pLevel, pPos);
if (sublevel != null) {
Vector3d min = sublevel.logicalPose().orientation().transform(voxelshape.bounds().minX, voxelshape.bounds().minY, voxelshape.bounds().minZ, new Vector3d());
Vector3d max = sublevel.logicalPose().orientation().transform(voxelshape.bounds().maxX, voxelshape.bounds().maxY, voxelshape.bounds().maxZ, new Vector3d());
AABB rotatedBounds = new AABB(min.x, min.y, min.z, max.x, max.y, max.z);
voxelshape = Shapes.create(rotatedBounds);
}
VoxelShape voxelshape1 = voxelshape.move(movePos.x, movePos.y, movePos.z);
if (pEntity.getBoundingBox().intersects(voxelshape1.bounds())) {
pLevel.getBlockEntity(pPos, BlockRegistry.PORTAL_FRAME_BLOCK_ENTITY.get()).ifPresent(tile -> tile.setActive()/*tile.teleport(pEntity)*/);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.redspace.ironsspellbooks.block.portal_frame;

import dev.ryanhcode.sable.companion.SableCompanion;
import io.redspace.ironsspellbooks.capabilities.magic.PortalManager;
import io.redspace.ironsspellbooks.entity.spells.portal.PortalData;
import io.redspace.ironsspellbooks.entity.spells.portal.PortalPos;
import io.redspace.ironsspellbooks.registries.BlockRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
Expand All @@ -20,8 +22,11 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.portal.DimensionTransition;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3d;

import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -144,14 +149,20 @@ public void teleport(Entity entity) {
//PortalManager.INSTANCE.addPortalCooldown(entity, portalData.portalEntityId2);
portalData.getConnectedPortalPos(uuid).ifPresent(portalPos -> {
Vec3 destination = portalPos.pos();
float rotation = portalPos.rotation();
var sublevel = SableCompanion.INSTANCE.getContaining(serverLevel, destination);
if (sublevel != null) {
rotation += (float) Math.toDegrees(sublevel.logicalPose().orientation().angle());
destination = destination.add(Vec3.directionFromRotation(0, portalPos.rotation()).scale(0.25));
}
serverLevel.playSound(null, this.getBlockPos(), SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1f, 1f);
if (serverLevel.dimension().equals(portalPos.dimension())) {
entity.teleportTo(serverLevel, destination.x, destination.y, destination.z, RelativeMovement.ROTATION, portalPos.rotation(), entity.getXRot());
entity.teleportTo(serverLevel, destination.x, destination.y, destination.z, RelativeMovement.ROTATION, rotation, entity.getXRot());
} else {
var server = serverLevel.getServer();
var dim = server.getLevel(portalPos.dimension());
if (dim != null) {
entity.changeDimension(new DimensionTransition(dim, destination, Vec3.ZERO, portalPos.rotation(), entity.getXRot(), DimensionTransition.DO_NOTHING));
entity.changeDimension(new DimensionTransition(dim, destination, Vec3.ZERO, rotation, entity.getXRot(), DimensionTransition.DO_NOTHING));
dim.playSound(null, destination.x, destination.y, destination.z, SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 1f, 1f);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.redspace.ironsspellbooks.spells.nature;

import dev.ryanhcode.sable.companion.SableCompanion;
import io.redspace.ironsspellbooks.IronsSpellbooks;
import io.redspace.ironsspellbooks.api.config.DefaultConfig;
import io.redspace.ironsspellbooks.api.magic.MagicData;
Expand All @@ -13,6 +14,7 @@
import io.redspace.ironsspellbooks.registries.SoundRegistry;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Position;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand All @@ -34,6 +36,8 @@
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3d;
import org.joml.Vector3dc;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -131,20 +135,22 @@ public boolean checkPreCastConditions(Level level, int spellLevel, LivingEntity

@Override
public void onCast(Level world, int spellLevel, LivingEntity entity, CastSource castSource, MagicData playerMagicData) {
var blockhit = Utils.getTargetBlock(world, entity, ClipContext.Fluid.NONE, distance);
Vec3 vec = blockhit.getLocation();
var blockHit = Utils.getTargetBlock(world, entity, ClipContext.Fluid.NONE, distance);
BlockPos blockpos = blockHit.getBlockPos();
Vector3d translatedVec = SableCompanion.INSTANCE.projectOutOfSubLevel(world, new Vector3d(blockpos.getX(), blockpos.getY(), blockpos.getZ()));
Vec3 vec = new Vec3(translatedVec.x, translatedVec.y, translatedVec.z).add(0.5, 0.5, 0.5);
Vec3 particle = entity.getEyePosition().subtract(0, 0.1, 0);
int count = (int) vec.distanceTo(particle) * 2;
int count = (int) vec.distanceTo( particle) * 2;
for (int i = 0; i < count; i++) {
Vec3 pos = vec.add(particle.subtract(vec).scale((double) i / count));
MagicManager.spawnParticles(world, ParticleTypes.CRIT, pos.x, pos.y, pos.z, 1, 0, 0, 0, 0, false);
}
MagicManager.spawnParticles(world, ParticleTypes.CRIT, vec.x, vec.y, vec.z, 25, 0, 0, 0, 0.2, false);

if (canBreak(world, blockhit.getBlockPos(), getSpellPower(spellLevel, entity))) {
if (canBreak(world, blockHit.getBlockPos(), getSpellPower(spellLevel, entity))) {
if (!(entity instanceof ServerPlayer serverPlayer)
|| !net.neoforged.neoforge.common.CommonHooks.fireBlockBreak(world, serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer, blockhit.getBlockPos(), world.getBlockState(blockhit.getBlockPos())).isCanceled()) {
doDestroyBlock(world, blockhit.getBlockPos(), entity);
|| !net.neoforged.neoforge.common.CommonHooks.fireBlockBreak(world, serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer, blockHit.getBlockPos(), world.getBlockState(blockHit.getBlockPos())).isCanceled()) {
doDestroyBlock(world, blockHit.getBlockPos(), entity);
}
}
super.onCast(world, spellLevel, entity, castSource, playerMagicData);
Expand Down