Skip to content
Open

1.20 #114

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
## Changelog
**0.0.1-beta 67**
Fix inPortalAmbianceSound and postTPPortalAmbiance sounds

**0.0.1-beta 66**
Port to 1.21

**0.0.1-beta 65.5**
Remove test portals

**0.0.1-beta 65**
Fix crash when attempting to teleport through an incomplete portal.

**0.0.1-beta 63**
Re-Release old 1.19 versions. Fix compat with sodium

Expand Down
20 changes: 4 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven { url "https://api.modrinth.com/maven" }
}

dependencies {
Expand All @@ -21,17 +20,6 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

optionalDependency("maven.modrinth:sodium:mc1.20-0.4.10")
}

def optionalDependency(String dep) {
def exclude = {
exclude group: "net.fabricmc.fabric-api"
exclude group: "net.fabricmc"
}

dependencies.modCompileOnly(dep, exclude)
//dependencies.modRuntimeOnly(dep, exclude)
}

processResources {
Expand All @@ -43,7 +31,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
30 changes: 22 additions & 8 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.kyrptonaught.customportalapi.client.CustomPortalsModClient;
import net.kyrptonaught.customportalapi.interfaces.EntityInCustomPortal;
import net.kyrptonaught.customportalapi.portal.frame.PortalFrameTester;
import net.kyrptonaught.customportalapi.util.CustomPortalHelper;
import net.kyrptonaught.customportalapi.util.CustomTeleporter;
import net.kyrptonaught.customportalapi.util.PortalLink;
import net.minecraft.block.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
Expand All @@ -21,11 +22,11 @@
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.*;
import net.minecraft.world.tick.ScheduledTickView;
import org.jetbrains.annotations.Nullable;

public class CustomPortalBlock extends Block {
public class CustomPortalBlock extends Block implements Portal {
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS;
protected static final VoxelShape X_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 6.0D, 16.0D, 16.0D, 10.0D);
protected static final VoxelShape Z_SHAPE = Block.createCuboidShape(6.0D, 0.0D, 0.0D, 10.0D, 16.0D, 16.0D);
Expand All @@ -45,25 +46,27 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
};
}

public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
@Override
protected BlockState getStateForNeighborUpdate(BlockState state, WorldView world, ScheduledTickView tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, Random random) {
Block block = getPortalBase((World) world, pos);
PortalLink link = CustomPortalApiRegistry.getPortalLinkFromBase(block);
if (link != null) {
PortalFrameTester portalFrameTester = link.getFrameTester().createInstanceOfPortalFrameTester().init(world, pos, CustomPortalHelper.getAxisFrom(state), block);
PortalFrameTester portalFrameTester = link.getFrameTester().createInstanceOfPortalFrameTester().init((WorldAccess) world, pos, CustomPortalHelper.getAxisFrom(state), block);
if (portalFrameTester.isAlreadyLitPortalFrame())
return super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
return super.getStateForNeighborUpdate(state, world, tickView, pos, direction, neighborPos, neighborState, random);
}
//todo handle unknown portallink

return Blocks.AIR.getDefaultState();
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(AXIS);
}

@Environment(EnvType.CLIENT)
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
@Override
protected ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state, boolean includeData) {
return ItemStack.EMPTY;
}

Expand Down Expand Up @@ -98,21 +101,33 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando
}
}


@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
EntityInCustomPortal entityInPortal = (EntityInCustomPortal) entity;
entityInPortal.tickInPortal(pos.toImmutable());
if (!entityInPortal.didTeleport()) {
if (entityInPortal.getTimeInPortal() >= entity.getMaxNetherPortalTime()) {
entityInPortal.setDidTP(true);
if (!world.isClient)
CustomTeleporter.TPToDim(world, entity, getPortalBase(world, pos), pos);
}
if (entity.canUsePortals(false)) {
entity.tryUsePortal(this, pos);
}
}

public Block getPortalBase(World world, BlockPos pos) {
return CustomPortalHelper.getPortalBaseDefault(world, pos);
}

@Override
public int getPortalDelay(ServerWorld world, Entity entity) {
if (entity instanceof PlayerEntity playerEntity) {
return Math.max(1, world.getGameRules().getInt(playerEntity.getAbilities().invulnerable ? GameRules.PLAYERS_NETHER_PORTAL_CREATIVE_DELAY : GameRules.PLAYERS_NETHER_PORTAL_DEFAULT_DELAY));
} else {
return 0;
}
}

@Override
public @Nullable TeleportTarget createTeleportTarget(ServerWorld world, Entity entity, BlockPos pos) {
return CustomTeleporter.createTeleportTarget(world, entity, getPortalBase(world, pos), pos);
}

@Override
public Effect getPortalEffect() {
return Effect.CONFUSION;
}
}
Loading