0.1.6
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-20 14:53:53 -04:00
parent 5dbfb589ee
commit 4ebb0279fe
6 changed files with 32 additions and 13 deletions

View File

@ -1,5 +1,8 @@
# Changelog
**Beta 0.1.6**
* Improve Energy Teleporter Reliability
**Beta 0.1.5**
* Fix Energy Teleporter Y Issues Again

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.9.0+build.204
# Mod Properties
mod_version = 0.1.5
mod_version = 0.1.6
maven_group = com.thebrokenrail
# Dependencies

View File

@ -140,11 +140,13 @@ public class EnergyPortalBlock extends SimpleBlock {
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (!world.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(world, pos), BooleanBiFunction.AND)) {
World entityWorld = entity.getEntityWorld();
if (entityWorld == world && !entityWorld.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(entityWorld, pos), BooleanBiFunction.AND)) {
boolean cooling = ((PortalCooldownEntity) entity).isEnergyPortalCooldown();
((PortalCooldownEntity) entity).resetEnergyPortalCooldown();
if (!cooling) {
EnergyTeleporter.teleport((ServerWorld) world, entity.getPos(), pos, entity);
EnergyTeleporter.teleport((ServerWorld) entityWorld, entity.getPos(), pos, entity);
}
}
}

View File

@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.block.portal;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.mixin.ServerPlayerEntityAccessor;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -19,13 +20,19 @@ import net.minecraft.world.Heightmap;
import net.minecraft.world.World;
import java.util.EnumSet;
import java.util.UUID;
class EnergyTeleporter {
private static void teleport(Entity entity, ServerWorld to, Vec3d pos) {
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntityAccessor) entity).setInTeleportationState(true);
}
try {
TeleportCommand.teleport(null, entity, to, pos.getX(), pos.getY(), pos.getZ(), EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class), entity.yaw, entity.pitch, null);
} catch (CommandSyntaxException ignored) {
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntity) entity).networkHandler.syncWithPlayerPosition();
}
}
@ -33,8 +40,6 @@ class EnergyTeleporter {
BlockPos center = EnergyPortalBlock.getCenterPos(world, blockPos);
Vec3d offset = pos.subtract(Vec3d.ofBottomCenter(center));
UUID uuid = entity.getUuid();
RegistryKey<World> worldKey = world.getRegistryKey();
if (worldKey == World.OVERWORLD) {
teleportWithMultiplier(world, entity, center, offset, World.NETHER, 1d / HardcodedConfig.ENERGY_PORTAL_MULTIPLIER);
@ -45,15 +50,12 @@ class EnergyTeleporter {
}
if (entity instanceof ServerPlayerEntity) {
ServerPlayerEntity player = world.getServer().getPlayerManager().getPlayer(uuid);
if (player != null) {
player.playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
}
((ServerPlayerEntity) entity).playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
}
}
private static int convertY(int y, int oldHeight, int newHeight) {
int newY = (int) (((float) y / (float) oldHeight) * (float) newHeight);
int newY = (int) (((float) newHeight / (float) oldHeight) * (float) y);
int bottomY = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
int topY = newHeight - (bottomY + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP);

View File

@ -0,0 +1,11 @@
package com.thebrokenrail.energonrelics.mixin;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ServerPlayerEntity.class)
public interface ServerPlayerEntityAccessor {
@Accessor
void setInTeleportationState(boolean inTeleportationState);
}

View File

@ -15,7 +15,8 @@
"MixinEntity",
"MixinLivingEntity",
"MixinMinecraftServer",
"MixinWorld"
"MixinWorld",
"ServerPlayerEntityAccessor"
],
"injectors": {
"defaultRequire": 1