Merge pull request #200 from MalekiRe/1.17

Fixed Fray, Added Statue for Fray, Added Armor Duraility  and Random Unravled Fabric, Fixed Limbo Teleportation, Other Stuff.
This commit is contained in:
Waterpicker 2021-06-11 20:04:09 -05:00 committed by GitHub
commit d9a10d9e86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 675 additions and 41 deletions

View file

@ -113,7 +113,7 @@ public class AdvancementTab implements Consumer<Consumer<Advancement>> {
ModDimensions.DUNGEON,
null,
LightPredicate.ANY,
BlockPredicate.Builder.create().block(Blocks.CHEST).build(),
BlockPredicate.Builder.create().blocks(Blocks.CHEST).build(),
FluidPredicate.ANY
),
new ItemPredicate(

View file

@ -5,6 +5,9 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.util.registry.Registry;
import me.shedaniel.autoconfig.AutoConfig;
@ -15,6 +18,8 @@ import org.dimdev.dimdoors.block.door.DimensionalDoorBlockRegistrar;
import org.dimdev.dimdoors.block.door.data.condition.Condition;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.command.ModCommands;
import org.dimdev.dimdoors.enchantment.FrayedEnchantment;
import org.dimdev.dimdoors.enchantment.ModEnchants;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.criteria.ModCriteria;
import org.dimdev.dimdoors.entity.stat.ModStats;
@ -129,7 +134,7 @@ public class DimensionalDoorsInitializer implements ModInitializer {
ModSoundEvents.init();
ModParticleTypes.init();
ModCriteria.init();
ModEnchants.init();
dimensionalDoorItemRegistrar = new DimensionalDoorItemRegistrar(Registry.ITEM);
dimensionalDoorBlockRegistrar = new DimensionalDoorBlockRegistrar(Registry.BLOCK, dimensionalDoorItemRegistrar);

View file

@ -178,6 +178,8 @@ public final class ModConfig implements ConfigData {
@Tooltip public int armorDamageFray = 125;
@Tooltip public int grayScreenFray = 175;
@Tooltip public int unravelledStatueFray = 200;
@Tooltip public int minFrayForTickFray = 125;
@Tooltip public int unravledFabricInInventoryFray = 150;
}
}

View file

@ -1,9 +1,12 @@
package org.dimdev.dimdoors.block;
import net.minecraft.server.world.ServerWorld;
import org.apache.logging.log4j.Level;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
@ -65,6 +68,10 @@ public class DimensionalPortalBlock extends Block implements RiftProvider<Entran
world.setBlockState(pos, ModBlocks.DETACHED_RIFT.getDefaultState());
((DetachedRiftBlockEntity) world.getBlockEntity(pos)).setData(rift.getData());
DimensionalRegistry.getRiftRegistry().setOverworldRift(entity.getUuid(), new Location((ServerWorld) world, pos));
LOGGER.log(Level.INFO, "Set overworld rift location");
}
public BlockState rotate(BlockState state, BlockRotation rotation) {

View file

@ -3,7 +3,6 @@ package org.dimdev.dimdoors.block;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import org.dimdev.dimdoors.block.door.DimensionalTrapdoorBlock;
import org.dimdev.dimdoors.block.door.data.DoorData;
import org.dimdev.dimdoors.block.door.data.DoorDataReader;
@ -31,6 +30,10 @@ public final class ModBlocks {
public static final Map<DyeColor, Block> FABRIC_BLOCKS = new HashMap<>();
private static final Map<DyeColor, Block> ANCIENT_FABRIC_BLOCKS = new HashMap<>();
@RegistryEntry("stone_player")
public static final Block STONE_PLAYER = register(new Block(FabricBlockSettings.of(Material.STONE).strength(0.5F).breakByHand(true).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
@RegistryEntry("gold_door")
public static final Block GOLD_DOOR = register(new DoorBlock(FabricBlockSettings.of(Material.METAL, MapColor.GOLD).strength(5.0F).breakByHand(false).breakByTool(FabricToolTags.PICKAXES).nonOpaque()));
@ -145,24 +148,25 @@ public final class ModBlocks {
@RegistryEntry("black_ancient_fabric")
public static final Block BLACK_ANCIENT_FABRIC = registerAncientFabric(DyeColor.BLACK);
private static final FabricBlockSettings UNRAVELLED_FABRIC_BLOCK_SETTINGS = FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15).strength(0.3F, 0.3F);
@RegistryEntry("eternal_fluid")
public static final Block ETERNAL_FLUID = register(new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MapColor.RED).luminance(15)));
@RegistryEntry("decayed_block")
public static final Block DECAYED_BLOCK = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
public static final Block DECAYED_BLOCK = register(new UnravelledFabricBlock(UNRAVELLED_FABRIC_BLOCK_SETTINGS));
@RegistryEntry("unfolded_block")
public static final Block UNFOLDED_BLOCK = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
public static final Block UNFOLDED_BLOCK = register(new UnravelledFabricBlock(UNRAVELLED_FABRIC_BLOCK_SETTINGS));
@RegistryEntry("unwarped_block")
public static final Block UNWARPED_BLOCK = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
public static final Block UNWARPED_BLOCK = register(new UnravelledFabricBlock(UNRAVELLED_FABRIC_BLOCK_SETTINGS));
@RegistryEntry("unravelled_block")
public static final Block UNRAVELLED_BLOCK = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
public static final Block UNRAVELLED_BLOCK = register(new UnravelledFabricBlock(UNRAVELLED_FABRIC_BLOCK_SETTINGS));
@RegistryEntry("unravelled_fabric")
public static final Block UNRAVELLED_FABRIC = register(new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MapColor.BLACK).ticksRandomly().luminance(15)));
public static final Block UNRAVELLED_FABRIC = register(new UnravelledFabricBlock(UNRAVELLED_FABRIC_BLOCK_SETTINGS));
@RegistryEntry("marking_plate")
public static final Block MARKING_PLATE = register(new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).nonOpaque()));

View file

@ -1,6 +1,7 @@
package org.dimdev.dimdoors.block.door;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.minecraft.block.*;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.api.util.math.MathUtil;
import org.dimdev.dimdoors.api.util.math.TransformationMatrix3d;
@ -11,9 +12,6 @@ import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.entity.Entity;
@ -41,7 +39,8 @@ public class DimensionalDoorBlock extends WaterLoggableDoorBlock implements Rift
}
@Override
@SuppressWarnings("deprecation") // TODO: change from onEntityCollision to some method for checking if player crossed portal plane
@SuppressWarnings("deprecation")
// TODO: change from onEntityCollision to some method for checking if player crossed portal plane
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (world.isClient) {
return;
@ -120,6 +119,34 @@ public class DimensionalDoorBlock extends WaterLoggableDoorBlock implements Rift
}
}
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
DoubleBlockHalf doubleBlockHalf = state.get(HALF);
BlockPos blockPos = pos;
BlockState blockState = world.getBlockState(pos);
BlockEntity blockEntity = world.getBlockEntity(pos);
if (doubleBlockHalf == DoubleBlockHalf.UPPER) {
blockPos = pos.down();
blockState = world.getBlockState(blockPos);
blockEntity = world.getBlockEntity(blockPos);
if (blockState.isOf(state.getBlock()) && blockState.get(HALF) == DoubleBlockHalf.LOWER) {
world.setBlockState(blockPos, world.getFluidState(blockPos).getFluid() == Fluids.WATER ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState(), 35);
world.syncWorldEvent(player, 2001, blockPos, Block.getRawIdFromState(blockState));
}
if (blockEntity instanceof EntranceRiftBlockEntity
&& blockState.get(HALF) == DoubleBlockHalf.LOWER
&& !(player.isCreative()
&& !DimensionalDoorsInitializer.getConfig().getDoorsConfig().placeRiftsInCreativeMode
)
) {
world.setBlockState(blockPos, ModBlocks.DETACHED_RIFT.getDefaultState());
((DetachedRiftBlockEntity) world.getBlockEntity(blockPos)).setData(((EntranceRiftBlockEntity) blockEntity).getData());
}
}
super.onBreak(world, pos, state, player);
}
@Override
public VoxelShape getRaycastShape(BlockState state, BlockView world, BlockPos pos) {
return VoxelShapes.fullCube();
@ -138,6 +165,7 @@ public class DimensionalDoorBlock extends WaterLoggableDoorBlock implements Rift
.inverseRotate(MathUtil.directionEulerAngle(state.get(DoorBlock.FACING).getOpposite()));
}
@Override
public boolean isExitFlipped() {
return true;

View file

@ -2,12 +2,19 @@ package org.dimdev.dimdoors.block.entity;
import java.util.Optional;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
import org.dimdev.dimdoors.block.RiftProvider;
import org.dimdev.dimdoors.api.client.DefaultTransformation;
import org.dimdev.dimdoors.api.client.Transformer;
import org.dimdev.dimdoors.item.DimensionalDoorItem;
import org.dimdev.dimdoors.item.RiftKeyItem;
import org.dimdev.dimdoors.pockets.DefaultDungeonDestinations;
import org.dimdev.dimdoors.rift.registry.Rift;
@ -34,9 +41,11 @@ import net.minecraft.util.math.Vec3d;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
public class EntranceRiftBlockEntity extends RiftBlockEntity {
private static final EscapeTarget ESCAPE_TARGET = new EscapeTarget(true);
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked;
public EntranceRiftBlockEntity(BlockPos pos, BlockState state) {
@ -57,6 +66,8 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
@Override
public boolean teleport(Entity entity) {
//Sets the location where the player should be teleported back to if they are in limbo and try to escape, to be the netrance of the rift that took them into dungeons.
if (this.isLocked()) {
if (entity instanceof LivingEntity) {
ItemStack stack = ((LivingEntity) entity).getStackInHand(((LivingEntity) entity).getActiveHand());
@ -89,7 +100,13 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
BlockState state = this.getWorld().getBlockState(this.getPos());
Block block = state.getBlock();
Vec3d targetPos = Vec3d.ofCenter(this.pos).add(Vec3d.of(this.getOrientation().getOpposite().getVector()).multiply(DimensionalDoorsInitializer.getConfig().getGeneralConfig().teleportOffset + 0.5));
/*
Unused code that needs to be edited if there are other ways to get to limbo
But if it is only dimteleport and going through rifts then this code isn't nessecary
if(DimensionalRegistry.getRiftRegistry().getOverworldRift(entity.getUuid()) == null) {
DimensionalRegistry.getRiftRegistry().setOverworldRift(entity.getUuid(), new Location(World.OVERWORLD, ((ServerPlayerEntity)entity).getSpawnPointPosition()));
}
*/
if (block instanceof CoordinateTransformerBlock) {
CoordinateTransformerBlock transformer = (CoordinateTransformerBlock) block;

View file

@ -3,6 +3,8 @@ package org.dimdev.dimdoors.command;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.api.util.math.MathUtil;
@ -15,6 +17,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.EulerAngle;
import net.minecraft.util.math.Vec3d;
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
public class DimTeleportCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
@ -51,6 +54,9 @@ public class DimTeleportCommand {
}
private static int teleport(Entity entity, ServerWorld dimension, Vec3d pos, EulerAngle angle) {
if(entity instanceof PlayerEntity) {
DimensionalRegistry.getRiftRegistry().setOverworldRift(entity.getUuid(), new Location((ServerWorld) entity.getEntityWorld(), entity.getBlockPos()));
}
TeleportUtil.teleport(entity, dimension, pos, angle, entity.getVelocity());
return Command.SINGLE_SUCCESS;
}

View file

@ -0,0 +1,44 @@
package org.dimdev.dimdoors.command;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.command.argument.ColorArgumentType;
import net.minecraft.command.argument.DimensionArgumentType;
import net.minecraft.command.argument.Vec3ArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.MessageType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.EulerAngle;
import net.minecraft.util.math.Vec3d;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.api.util.math.MathUtil;
import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent;
public class FrayCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(CommandManager.literal("fray")
.then(CommandManager
.argument("amount", IntegerArgumentType.integer())
.executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().getPlayer();
return addFray(ctx.getSource(), Formatting.ITALIC, player, IntegerArgumentType.getInteger(ctx, "amount"));
})
)
);
}
private static int addFray(ServerCommandSource source, Formatting formatting, PlayerEntity player, int amount) {
PlayerModifiersComponent.incrementFray(player, amount);
final Text text = new LiteralText("added : " + amount + " player now has : " + PlayerModifiersComponent.getFray(player)).formatted(formatting);
source.getMinecraftServer().getPlayerManager().broadcastChatMessage(text, MessageType.CHAT, player.getUuid());
return Command.SINGLE_SUCCESS;
}
}

View file

@ -7,6 +7,7 @@ public final class ModCommands {
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
DimTeleportCommand.register(dispatcher);
PocketCommand.register(dispatcher);
FrayCommand.register(dispatcher);
});
}
}

View file

@ -0,0 +1,24 @@
package org.dimdev.dimdoors.enchantment;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
public class FrayedEnchantment extends Enchantment {
public FrayedEnchantment(Rarity weight, EnchantmentTarget type, EquipmentSlot[] slotTypes) {
super(weight, type, slotTypes);
}
@Override
public int getMinPower(int level) {
return 10000;
}
@Override
public int getMaxLevel() {
return 1;
}
@Override
public boolean isCursed(){
return true;
}
}

View file

@ -0,0 +1,24 @@
package org.dimdev.dimdoors.enchantment;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class ModEnchants {
public static Enchantment FRAYED_ENCHANTMENT;
public static Enchantment STRING_THEORY_ENCHANTMENT;
public static void init() {
FRAYED_ENCHANTMENT = Registry.register(
Registry.ENCHANTMENT,
new Identifier("dimdoors", "frayed"),
new FrayedEnchantment(Enchantment.Rarity.VERY_RARE, EnchantmentTarget.BREAKABLE, new EquipmentSlot[] {EquipmentSlot.MAINHAND, EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.HEAD, EquipmentSlot.LEGS})
);
STRING_THEORY_ENCHANTMENT = Registry.register(
Registry.ENCHANTMENT,
new Identifier("dimdoors", "string_theory"),
new StringTheoryEnchantment(Enchantment.Rarity.UNCOMMON, EnchantmentTarget.WEARABLE, new EquipmentSlot[] {EquipmentSlot.FEET, EquipmentSlot.LEGS, EquipmentSlot.CHEST, EquipmentSlot.HEAD})
);
}
}

View file

@ -0,0 +1,23 @@
package org.dimdev.dimdoors.enchantment;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
public class StringTheoryEnchantment extends Enchantment {
public StringTheoryEnchantment(Rarity weight, EnchantmentTarget type, EquipmentSlot[] slotTypes) {
super(weight, type, slotTypes);
}
@Override
public int getMinPower(int level) {
return 10000;
}
@Override
public int getMaxLevel() {
return 1;
}
public boolean isTreasure() {
return true;
}
}

View file

@ -108,7 +108,7 @@ public class MonolithAggroGoal extends Goal {
this.target.teleport(this.target.getX(), this.target.getY() + 256, this.target.getZ());
this.target.world.playSound(null, new BlockPos(this.target.getPos()), ModSoundEvents.CRACK, SoundCategory.HOSTILE, 13, 1);
this.target.incrementStat(ModStats.TIMES_TELEPORTED_BY_MONOLITH);
PlayerModifiersComponent.incrementFray(this.target, DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.monolithTeleportationIncrement);
PlayerModifiersComponent.incrementFray(this.target, -DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.monolithTeleportationIncrement);
ServerPacketHandler.get((ServerPlayerEntity) this.target).sendPacket(new MonolithTeleportParticlesPacket());
}
}

View file

@ -10,7 +10,6 @@ public class ModStats {
public static final Identifier TIMES_SENT_TO_LIMBO = StatsAccessor.invokeRegister("dimdoors:times_sent_to_limbo", StatFormatter.DEFAULT);
public static final Identifier TIMES_TELEPORTED_BY_MONOLITH = StatsAccessor.invokeRegister("dimdoors:times_teleported_by_monolith", StatFormatter.DEFAULT);
public static final Identifier TIMES_BEEN_TO_DUNGEON = StatsAccessor.invokeRegister("dimdoors:times_been_to_dungeon", StatFormatter.DEFAULT);
public static void init() {
// just loads the class
}

View file

@ -42,6 +42,9 @@ public final class ModItems {
.icon(() -> new ItemStack(ModItems.RIFT_BLADE))
.build();
@RegistryEntry("stone_player")
public static final Item STONE_PLAYER = create(ModBlocks.STONE_PLAYER);
@RegistryEntry("quartz_door")
public static final Item QUARTZ_DOOR = create(ModBlocks.QUARTZ_DOOR);

View file

@ -1,8 +1,11 @@
package org.dimdev.dimdoors.mixin;
import net.minecraft.item.ItemStack;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.item.ModItems;
import org.dimdev.dimdoors.mixin.accessor.EntityAccessor;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@ -18,8 +21,11 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import java.util.Random;
@Mixin(value = PlayerEntity.class, priority = 900)
public abstract class PlayerEntityMixin extends LivingEntity {
@Shadow
public abstract void incrementStat(Identifier stat);
@ -27,9 +33,10 @@ public abstract class PlayerEntityMixin extends LivingEntity {
super(entityType, world);
}
@Inject(method = "handleFallDamage", at = @At("HEAD"), cancellable = true)
public void handleLimboFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
if(this.world.getDimension().equals(ModDimensions.LIMBO_DIMENSION.getDimension())) {
if (ModDimensions.isLimboDimension(world)) {
cir.setReturnValue(false);
}
}

View file

@ -1,11 +1,26 @@
package org.dimdev.dimdoors.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.network.ServerRecipeBook;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.UnravelledFabricBlock;
import org.dimdev.dimdoors.criteria.ModCriteria;
import org.dimdev.dimdoors.enchantment.ModEnchants;
import org.dimdev.dimdoors.entity.limbo.LimboEntranceSource;
import org.dimdev.dimdoors.entity.stat.ModStats;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.item.ModItems;
import org.dimdev.dimdoors.network.ExtendedServerPlayNetworkHandler;
import org.dimdev.dimdoors.network.packet.s2c.PlayerInventorySlotUpdateS2CPacket;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -19,12 +34,176 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import java.util.Random;
@Mixin(value = ServerPlayerEntity.class, priority = 900)
public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin {
@Shadow
@Final
private ServerRecipeBook recipeBook;
@Shadow
public abstract void readCustomDataFromNbt(NbtCompound nbt);
private static final float RANDOM_ACTION_CHANCE = 0.1F;
private static final float CHANCE_TO_DECREASE_ARMOR_DURABILITY = 0.03F;
private static final float CHANCE_TO_REPLACE_ITEMSLOT_WITH_UNRAVLED_FABRIC = 0.005F;
private static final float CHANCE_TO_ENCHANT_WITH_FRAY = 0.01F;
private static final float CHANCE_TO_MAKE_LIMBO_LIKE_OTHER_DIMENSIONS = 0.1F;
private static final float RANDOM_INCREMENT_FRAY_CHANCE = 0.1F;
private static final int CHUNK_SIZES = 25;
private static final int POSITION_AWAY = 50;
private static final float RANDOM_LIQUID_CHANCE = 0.7F;
Random random = new Random();
public ServerPlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World world) {
super(entityType, world);
}
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
public void playerTickMixin(CallbackInfo ci) {
if (random.nextFloat() <= RANDOM_ACTION_CHANCE) {
if(random.nextFloat() <= RANDOM_INCREMENT_FRAY_CHANCE && PlayerModifiersComponent.getFray((PlayerEntity) (Object)this) < 180) {
PlayerModifiersComponent.incrementFray((PlayerEntity) (Object)this, 1);
}
if (PlayerModifiersComponent.getFray(this) >= 125) {
doRandomFunction(this);
}
if(ModDimensions.isLimboDimension(((PlayerEntity)(Object)(this)).getEntityWorld())) {
tryAddingFrayEnchantment((PlayerEntity) (Object)this);
tryMakingLimboLikeOtherDimensions((PlayerEntity)(Object)this);
}
}
}
private boolean isValidBlockToReplace(World world, BlockPos pos) {
return world.getBlockState(pos.up()).isAir() && world.getBlockState(pos).getBlock() instanceof UnravelledFabricBlock;
}
private void makeLimboLikeOverworld(PlayerEntity player) {
/*
World world = player.getEntityWorld();
BlockPos pos = player.getBlockPos().add(random.nextInt(random.nextInt(POSITION_AWAY)), 0, random.nextInt(POSITION_AWAY));
if(random.nextFloat() <= RANDOM_LIQUID_CHANCE) {
makeSpotOfLiquid(world, pos, Blocks.WATER.getDefaultState(), 3);
}
BlockPos.iterateOutwards(pos, CHUNK_SIZES, 15, CHUNK_SIZES).forEach( (blockPos -> {
if(isValidBlockToReplace(world, blockPos)) {
world.setBlockState(blockPos, Blocks.GRASS_BLOCK.getDefaultState());
}
}));
*/
}
private void makeLimboLikeEnd(PlayerEntity player) {
/*
World world = player.getEntityWorld();
BlockPos pos = player.getBlockPos().add(random.nextInt(POSITION_AWAY), 0, random.nextInt(POSITION_AWAY));
BlockPos.iterateOutwards(pos, CHUNK_SIZES, 15, CHUNK_SIZES).forEach( (blockPos -> {
if(isValidBlockToReplace(world, blockPos)) {
world.setBlockState(blockPos, Blocks.END_STONE.getDefaultState());
}
}));
*/
}
private void makeSpotOfLiquid(World world, BlockPos pos, BlockState state, int range) {
BlockPos.iterateOutwards(pos, random.nextInt(range), random.nextInt(range), random.nextInt(range)).forEach( (blockPos -> {
if(isValidBlockToReplace(world, blockPos)) {
world.setBlockState(blockPos, state);
}
}));
}
private void makeLimboLikeNether(PlayerEntity player) {
/*
World world = player.getEntityWorld();
BlockPos pos = player.getBlockPos().add(random.nextInt(POSITION_AWAY), 0, random.nextInt(POSITION_AWAY));
if(random.nextFloat() <= RANDOM_LIQUID_CHANCE) {
makeSpotOfLiquid(world, pos, Blocks.LAVA.getDefaultState(), 10);
}
BlockPos.iterateOutwards(pos, CHUNK_SIZES, 15, CHUNK_SIZES).forEach( (blockPos -> {
if(isValidBlockToReplace(world, blockPos)) {
world.setBlockState(blockPos, Blocks.NETHERRACK.getDefaultState());
}
}));
*/
}
private void tryMakingLimboLikeOtherDimensions(PlayerEntity player) {
if(random.nextFloat() > CHANCE_TO_MAKE_LIMBO_LIKE_OTHER_DIMENSIONS) {
return;
}
switch (random.nextInt(3)) {
case 0 : makeLimboLikeOverworld(player); break;
case 1 : makeLimboLikeNether(player); break;
case 2 : makeLimboLikeEnd(player); break;
}
}
private void doRandomFunction(LivingEntity player) {
switch (random.nextInt(2)) {
case 0:
decreaseArmorDurability((PlayerEntity) player);
break;
case 1:
addRandomUnravledFabric((PlayerEntity) player);
break;
default:
}
}
private void tryAddingFrayEnchantment(PlayerEntity player) {
if (!(random.nextFloat() <= CHANCE_TO_ENCHANT_WITH_FRAY)) {
return;
}
int slot = random.nextInt(player.getInventory().size());
if (!player.getInventory().getStack(slot).isEnchantable()) {
return;
}
ItemStack stack = player.getInventory().getStack(slot);
stack.addEnchantment(ModEnchants.FRAYED_ENCHANTMENT, 1);
player.getInventory().setStack(slot, stack);
((ExtendedServerPlayNetworkHandler) (Object) ((ServerPlayerEntity) (Object) this).networkHandler).getDimDoorsPacketHandler().sendPacket(new PlayerInventorySlotUpdateS2CPacket(slot, stack));
}
//TODO: Fix this shit so it syncs.
private void addRandomUnravledFabric(PlayerEntity player) {
if (PlayerModifiersComponent.getFray(player) < DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.unravledFabricInInventoryFray)
return;
if (!(random.nextFloat() <= CHANCE_TO_REPLACE_ITEMSLOT_WITH_UNRAVLED_FABRIC))
return;
int slot = random.nextInt(player.getInventory().main.size());
if (!player.getInventory().main.get(slot).isEmpty() && !(player.getInventory().main.get(slot).getItem() == ModItems.UNRAVELLED_FABRIC))
return;
if (player.getInventory().main.get(slot).getCount() >= 64)
return;
ItemStack stack = new ItemStack(ModItems.UNRAVELLED_FABRIC, 1 + player.getInventory().main.get(slot).getCount());
player.getInventory().main.set(slot, stack);
((ExtendedServerPlayNetworkHandler) (Object) ((ServerPlayerEntity) (Object) this).networkHandler).getDimDoorsPacketHandler().sendPacket(new PlayerInventorySlotUpdateS2CPacket(slot, stack));
}
private void decreaseArmorDurability(PlayerEntity player) {
if (PlayerModifiersComponent.getFray(player) < DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.unravledFabricInInventoryFray)
return;
for (int i = 0; i < player.getInventory().armor.size(); i++)
if (random.nextFloat() <= CHANCE_TO_DECREASE_ARMOR_DURABILITY)
player.getArmorItems().forEach((itemStack) -> {
itemStack.setDamage(itemStack.getDamage() + 1);
});
}
@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true)
public void checkDeathServer(DamageSource source, CallbackInfo ci) {
this.doOnDeathStuff(source, ci);
@ -45,4 +224,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin {
ModCriteria.POCKET_SPAWN_POINT_SET.trigger((ServerPlayerEntity) (Object) this);
}
}
}

View file

@ -1,9 +1,18 @@
package org.dimdev.dimdoors.mixin.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.level.component.PlayerModifiersComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -16,11 +25,69 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
@Mixin(InGameHud.class)
public class InGameHudMixin {
// @Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V"), method = "renderVignetteOverlay(Lnet/minecraft/entity/Entity;)V")
public abstract class InGameHudMixin{
private int frame = 0;
private static final float OVERLAY_OPACITY_ADJUSTEMENT = 1.5F;
private ModConfig.Player config = DimensionalDoorsInitializer.getConfig().getPlayerConfig();
@Shadow
private int scaledHeight;
@Shadow
private int scaledWidth;
@Shadow
protected abstract PlayerEntity getCameraPlayer();
// @Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V"), method = "renderVignetteOverlay(Lnet/minecraft/entity/Entity;)V")
// public void renderVignetteOverlay(Entity entity, CallbackInfo info) {
// if (ModDimensions.isLimboDimension(entity.world)) {
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
// }
// }
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void renderOverlayMixin(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
float overlayOpacity = (config.fray.grayScreenFray - PlayerModifiersComponent.getFray(getCameraPlayer()))/(config.fray.grayScreenFray - (float)config.fray.maxFray);
if (PlayerModifiersComponent.getFray(getCameraPlayer()) > config.fray.grayScreenFray) {
System.out.println(overlayOpacity);
this.renderOverlay(new Identifier("dimdoors", "textures/other/static.png"), overlayOpacity);
}
}
private void renderOverlay(Identifier texture, float opacity) {
frame++;
if(frame > 6)
frame = 0;
float frameAdjustment = (opacity);
opacity /= OVERLAY_OPACITY_ADJUSTEMENT;
float amountMoved = ((float)frame)/6F;
float up = amountMoved;
float down = 1*amountMoved + 1f/6f;
float left = frameAdjustment;
float right = 1-frameAdjustment;
/*
up = up+frameAdjustment;
down = down-frameAdjustment;
*/
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, opacity);
RenderSystem.setShaderTexture(0, texture);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(0.0D, (double)this.scaledHeight, -90.0D).texture(left, up).next(); //Upper left hand corner
bufferBuilder.vertex((double)this.scaledWidth, (double)this.scaledHeight, -90.0D).texture(right, up).next(); //Upper right hand corner
bufferBuilder.vertex((double)this.scaledWidth, 0.0D, -90.0D).texture(right, down).next(); //Lower left hand corner
bufferBuilder.vertex(0.0D, 0.0D, -90.0D).texture(left, down).next();//Lower right hand corner.
tessellator.draw();
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
}
}

View file

@ -5,10 +5,12 @@ import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.util.Pair;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.api.util.GraphUtils;
@ -33,7 +35,9 @@ public class RiftRegistry {
protected Map<UUID, PlayerRiftPointer> lastPrivatePocketEntrances = new HashMap<>(); // Player UUID -> last rift used to exit pocket
protected Map<UUID, PlayerRiftPointer> lastPrivatePocketExits = new HashMap<>(); // Player UUID -> last rift used to enter pocket
protected Map<UUID, PlayerRiftPointer> overworldRifts = new HashMap<>(); // Player UUID -> rift used to exit the overworld
//I know this is sorta hacky, but overworldRifts can't be set for some reason it doesn't think that the rift location exists.
//TODO: Fix this shit so that u can use overworldRifts instead of overworldLocations. NVM this is better cause we can teleport to locations that aren't rifts.
protected Map<UUID, Location> overworldLocations = new HashMap<>();
public static RiftRegistry fromNbt(Map<RegistryKey<World>, PocketDirectory> pocketRegistry, NbtCompound nbt) {
// Read rifts in this dimension
@ -354,14 +358,28 @@ public class RiftRegistry {
}
public Location getOverworldRift(UUID playerUUID) {
/*
PlayerRiftPointer entrancePointer = this.overworldRifts.get(playerUUID);
Rift rift = (Rift) GraphUtils.followPointer(this.graph, entrancePointer);
for (int i = 0; i < 10; i++) {
if (rift == null) {
LOGGER.log(Level.ERROR, "rift is null for getOverworldRift");
} else {
LOGGER.log(Level.INFO, "rift location " + rift.getLocation().getWorld() + " and pos " + rift.getLocation().pos.toString());
}
}
return rift != null ? rift.getLocation() : null;
*/
return overworldLocations.get(playerUUID);
}
public void setOverworldRift(UUID playerUUID, Location rift) {
LOGGER.debug("Setting last used overworld rift for " + playerUUID + " at " + rift);
/*
LOGGER.log(Level.INFO, "Setting last used overworld rift for " + playerUUID + " at " + rift.getWorld() + " pos at " + rift.getBlockPos());
this.setPlayerRiftPointer(playerUUID, rift, this.overworldRifts);
*/
overworldLocations.put(playerUUID, rift);
}
public Collection<Rift> getRifts() {

View file

@ -7,6 +7,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
@ -47,6 +48,8 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
UUID uuid = entity.getUuid();
if (uuid != null) {
Location destLoc = DimensionalRegistry.getRiftRegistry().getOverworldRift(uuid);
//This right here is changed to work with a slightly diff system where we just store where we want to player to go, after they leave limbo.
/*
if (destLoc != null && destLoc.getBlockEntity() instanceof RiftBlockEntity || this.canEscapeLimbo) {
Location location = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getBlockPos())).projectToWorld(false);
TeleportUtil.teleport(entity, location.getWorld(), location.getBlockPos(), relativeAngle, relativeVelocity);
@ -60,6 +63,24 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
TeleportUtil.teleport(entity, ModDimensions.LIMBO_DIMENSION, new BlockPos(this.location.getX(), this.location.getY(), this.location.getZ()), relativeAngle, relativeVelocity);
}
}
*/
if(destLoc != null && this.canEscapeLimbo) {
Location location = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, destLoc.pos)).projectToWorld(false);
TeleportUtil.teleport(entity, location.getWorld(), location.getBlockPos(), relativeAngle, relativeVelocity);
BlockPos.iterateOutwards(location.pos.add(0, -4, 0), 3, 2, 3).forEach((pos1 -> {
location.getWorld().setBlockState(pos1, ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
}));
}
else {
if (destLoc == null) {
chat(entity, new TranslatableText("rifts.destinations.escape.did_not_use_rift"));
} else {
chat(entity, new TranslatableText("rifts.destinations.escape.rift_has_closed"));
}
if (ModDimensions.LIMBO_DIMENSION != null) {
TeleportUtil.teleport(entity, ModDimensions.LIMBO_DIMENSION, new BlockPos(this.location.getX(), this.location.getY(), this.location.getZ()), relativeAngle, relativeVelocity);
}
}
return true;
} else {
return false; // No escape info for that entity

View file

@ -1,8 +1,10 @@
package org.dimdev.dimdoors.world;
import net.minecraft.world.biome.*;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.mixin.accessor.BuiltinBiomesAccessor;
import org.dimdev.dimdoors.particle.client.RiftParticleEffect;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.feature.ModFeatures;
@ -14,10 +16,6 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
@ -97,6 +95,7 @@ public final class ModBiomes {
.music(new MusicSound(ModSoundEvents.CREEPY, 0, 0, true))
.skyColor(0x404040)
.grassColor(0)
.particleConfig(new BiomeParticleConfig(new RiftParticleEffect(0.2f, 2000), 0.003F))
.build()
)
.generationSettings(new GenerationSettings.Builder()

View file

@ -2,6 +2,9 @@ package org.dimdev.dimdoors.world.level.component;
import dev.onyxstudios.cca.api.v3.component.ComponentV3;
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import org.dimdev.dimdoors.DimensionalDoorsComponents;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
@ -10,6 +13,11 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.MathHelper;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.enchantment.ModEnchants;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
public class PlayerModifiersComponent implements ComponentV3, AutoSyncedComponent {
private int fray = 0;
@ -41,25 +49,51 @@ public class PlayerModifiersComponent implements ComponentV3, AutoSyncedComponen
return fray;
}
public void resetFray() {fray = 0;}
public int incrementFray(int amount) {
return (fray = MathHelper.clamp(fray - amount, 0, DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.maxFray));
return (fray = MathHelper.clamp(fray + amount, 0, DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.maxFray));
}
public static PlayerModifiersComponent get(PlayerEntity player) {
return DimensionalDoorsComponents.PLAYER_MODIFIERS_COMPONENT_KEY.get(player);
}
public static int incrementFray(PlayerEntity player, int amount) {
int v = get(player).incrementFray(amount);
PlayerModifiersComponent.sync(player);
return v;
public static void resetFray(PlayerEntity player) {
get(player).resetFray();
}
public static int getFray(PlayerEntity player) {
return get(player).getFray();
public static int getFray(LivingEntity player) {
return get((PlayerEntity) player).getFray();
}
public static void sync(PlayerEntity player) {
DimensionalDoorsComponents.PLAYER_MODIFIERS_COMPONENT_KEY.sync(player);
}
public static int incrementFray(PlayerEntity player, int amount) {
for(int i = 0; i < player.getInventory().armor.size(); i++) {
if(EnchantmentHelper.getLevel(ModEnchants.STRING_THEORY_ENCHANTMENT, player.getInventory().armor.get(i)) > 0) {
amount *= 0.85;
}
}
int v = get(player).incrementFray(amount);
PlayerModifiersComponent.sync(player);
if(getFray(player) == DimensionalDoorsInitializer.getConfig().getPlayerConfig().fray.maxFray) {
killPlayer(player);
}
System.out.println("fray amount is : " + getFray(player));
return v;
}
private static void killPlayer(PlayerEntity player) {
player.kill();
//Fray should be reset by mixinging into the player class and changing the kill event or some other funciton that happens when a player dies.
//This is just temporary
//On second thought, this should get rid of fray, and fray should stay with the player otherwise, that way they have to actively try to get rid of it without just like, dying.
resetFray(player);
player.getEntityWorld().setBlockState(player.getBlockPos(), ModBlocks.STONE_PLAYER.getDefaultState(), 3);
}
}

View file

@ -89,9 +89,20 @@ public class VirtualLocation {
float spread = DimensionalDoorsInitializer.getConfig().getGeneralConfig().depthSpreadFactor * this.depth;
int newX = (int) (this.x + spread * 2 * (Math.random() - 0.5));
int newZ = (int) (this.z + spread * 2 * (Math.random() - 0.5));
BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(newX, 0, newZ));
//BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(newX, 1, newZ));
BlockPos pos = getTopPos(world, new BlockPos(newX, 255, newZ));
return new Location(world, pos);
}
private static BlockPos getTopPos(World world, BlockPos pos) {
while(world.getBlockState(pos).isAir()) {
pos = pos.down();
}
while(world.getBlockState(pos).isSolidBlock(world, pos)) {
pos = pos.up();
}
pos = pos.up(2);
return pos;
}
public RegistryKey<World> getWorld() {
return this.world;

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "dimdoors:block/stone_player"
}
}
}

View file

@ -410,5 +410,7 @@
"resourcePackActivationType.alwaysEnabled": "Always Enabled",
"dimdoors.mode.enable": "Enable",
"dimdoors.mode.disable": "Disable"
"dimdoors.mode.disable": "Disable",
"enchantment.dimdoors.frayed" : "Frayed"
}

View file

@ -0,0 +1,100 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "dimdoors:block/stone_player",
"particle": "dimdoors:block/stone_player"
},
"elements": [
{
"name": "head",
"from": [4, 23.5, 4],
"to": [12, 31.5, 12],
"faces": {
"north": {"uv": [2, 2, 4, 4], "texture": "#0"},
"east": {"uv": [0, 2, 2, 4], "texture": "#0"},
"south": {"uv": [6, 2, 8, 4], "texture": "#0"},
"west": {"uv": [4, 2, 6, 4], "texture": "#0"},
"up": {"uv": [4, 2, 2, 0], "texture": "#0"},
"down": {"uv": [6, 0, 4, 2], "texture": "#missing"}
}
},
{
"name": "body",
"from": [4, 11.5, 6],
"to": [12, 23.5, 10],
"faces": {
"north": {"uv": [5, 5, 7, 7.98], "texture": "#0"},
"east": {"uv": [4, 5, 5, 8], "texture": "#missing"},
"south": {"uv": [8, 5, 10, 8], "texture": "#0"},
"west": {"uv": [7, 5, 8, 7.98], "texture": "#missing"},
"up": {"uv": [7, 5, 5, 4], "texture": "#missing"},
"down": {"uv": [9, 4, 7, 5], "texture": "#missing"}
}
},
{
"name": "right_arm",
"from": [12, 11.5, 6],
"to": [16, 23.5, 10],
"faces": {
"north": {"uv": [11, 5, 12, 8], "texture": "#0"},
"east": {"uv": [10, 5, 11, 8], "texture": "#0"},
"south": {"uv": [13, 5, 14, 8], "texture": "#0"},
"west": {"uv": [12, 5, 13, 8], "texture": "#missing"},
"up": {"uv": [12, 5, 11, 4], "texture": "#0"},
"down": {"uv": [13, 4, 12, 5], "texture": "#missing"}
}
},
{
"name": "left_arm",
"from": [0, 11.5, 6],
"to": [4, 23.5, 10],
"faces": {
"north": {"uv": [9, 13, 10, 16], "texture": "#0"},
"east": {"uv": [8, 13, 9, 16], "texture": "#missing"},
"south": {"uv": [11, 13, 12, 16], "texture": "#0"},
"west": {"uv": [10, 13, 11, 16], "texture": "#0"},
"up": {"uv": [10, 13, 9, 12], "texture": "#0"},
"down": {"uv": [11, 12, 10, 13], "texture": "#missing"}
}
},
{
"name": "right_leg",
"from": [8, -0.5, 6],
"to": [12, 11.5, 10],
"faces": {
"north": {"uv": [1, 5, 2, 8], "texture": "#0"},
"east": {"uv": [0, 5, 1, 8], "texture": "#0"},
"south": {"uv": [3, 5, 4, 8], "texture": "#0"},
"west": {"uv": [2, 5, 3, 8], "texture": "#missing"},
"up": {"uv": [2, 5, 1, 4], "texture": "#missing"},
"down": {"uv": [3, 4, 2, 5], "texture": "#0"}
}
},
{
"name": "left_leg",
"from": [4, -0.5, 6],
"to": [8, 11.5, 10],
"faces": {
"north": {"uv": [5, 13, 6, 16], "texture": "#0"},
"east": {"uv": [4, 13, 5, 16], "texture": "#missing"},
"south": {"uv": [7, 13, 8, 16], "texture": "#0"},
"west": {"uv": [6, 13, 7, 16], "texture": "#0"},
"up": {"uv": [6, 13, 5, 12], "texture": "#missing"},
"down": {"uv": [7, 12, 6, 13], "texture": "#0"}
}
}
],
"display": {
"head": {
"translation": [0, -29, 0],
"scale": [1.6, 1.6, 1.6]
}
},
"groups": [
{
"name": "steve",
"origin": [8, 8, 8],
"children": [0, 1, 2, 3, 4, 5]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -22,7 +22,7 @@
"conditions": {
"items": [
{
"tag": "dimdoors:fabric"
"tag": ["dimdoors:fabric"]
}
]
}

View file

@ -22,7 +22,7 @@
"conditions": {
"items": [
{
"item": "minecraft:ender_pearl"
"items": ["minecraft:ender_pearl"]
}
]
}

View file

@ -22,7 +22,7 @@
"conditions": {
"items": [
{
"item": "dimdoors:world_thread"
"items": ["dimdoors:world_thread"]
}
]
}

View file

@ -22,7 +22,7 @@
"conditions": {
"items": [
{
"item": "dimdoors:unravelled_fabric"
"items": ["dimdoors:unravelled_fabric"]
}
]
}