Limbo now corrupts the overworld in a corrupty looking way.

This commit is contained in:
MalekiRe 2021-06-13 20:21:57 -07:00
parent 346b5ed158
commit ad69c22281
3 changed files with 63 additions and 1 deletions

View file

@ -196,6 +196,7 @@ public final class ModConfig implements ConfigData {
@Tooltip public boolean universalLimbo = false;
@Tooltip public boolean hardcoreLimbo = false;
@Tooltip public double decaySpreadChance = 0.5;
@Tooltip public float limboBlocksCorruptingOverworldAmount = 5;
}
public static class Graphics {

View file

@ -0,0 +1,48 @@
package org.dimdev.dimdoors.block;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import org.dimdev.dimdoors.item.ModItems;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class UnravelUtil {
public static final Set<Block> whitelistedBlocksForLimboRemoval = new HashSet<>();
public static final Map<Item, Item> unravelItemsMap = new HashMap<>();
public static final Map<Block, Block> unravelBlocksMap = new HashMap<>();
static {
whitelistedBlocksForLimboRemoval.add(Blocks.GRASS_BLOCK);
whitelistedBlocksForLimboRemoval.add(Blocks.STONE);
whitelistedBlocksForLimboRemoval.add(Blocks.SAND);
whitelistedBlocksForLimboRemoval.add(Blocks.SANDSTONE);
whitelistedBlocksForLimboRemoval.add(Blocks.ACACIA_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.AZALEA_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.BIRCH_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.DARK_OAK_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.JUNGLE_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.SPRUCE_LEAVES);
whitelistedBlocksForLimboRemoval.add(Blocks.TERRACOTTA);
whitelistedBlocksForLimboRemoval.add(Blocks.RED_SAND);
//Add unravled items when we have them, for now, we do this.
unravelItemsMap.put(Items.STONE, Items.COBBLESTONE);
unravelItemsMap.put(Items.COBBLESTONE, Items.GRAVEL);
unravelItemsMap.put(Items.GRAVEL, Items.SANDSTONE);
unravelItemsMap.put(Items.SANDSTONE, Items.SAND);
unravelItemsMap.put(Items.SAND, ModItems.UNRAVELLED_FABRIC);
for(Item item : unravelItemsMap.keySet()) {
Item item2 = unravelItemsMap.get(item);
if(item instanceof BlockItem && item2 instanceof BlockItem) {
unravelBlocksMap.put(((BlockItem)item).getBlock(), ((BlockItem)item2).getBlock());
}
}
unravelBlocksMap.put(Blocks.WATER, ModBlocks.UNFOLDED_BLOCK);
}
}

View file

@ -1,10 +1,12 @@
package org.dimdev.dimdoors.rift.targets;
import java.util.Random;
import java.util.UUID;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.sk89q.worldedit.util.formatting.text.BlockNbtComponent;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
@ -12,10 +14,13 @@ 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.ModConfig;
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.UnravelUtil;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.level.registry.DimensionalRegistry;
@ -91,8 +96,16 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
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);
Random random = new Random();
BlockPos.iterateOutwards(location.pos.add(0, -4, 0), 3, 2, 3).forEach((pos1 -> {
location.getWorld().setBlockState(pos1, ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
if(random.nextFloat() < (1/((float)location.pos.getSquaredDistance(pos1)))* DimensionalDoorsInitializer.getConfig().getLimboConfig().limboBlocksCorruptingOverworldAmount) {
Block block = location.getWorld().getBlockState(pos1).getBlock();
if(UnravelUtil.unravelBlocksMap.containsKey(block))
location.getWorld().setBlockState(pos1, UnravelUtil.unravelBlocksMap.get(block).getDefaultState());
else if(UnravelUtil.whitelistedBlocksForLimboRemoval.contains(block)) {
location.getWorld().setBlockState(pos1, ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
}
}
}));
}
else {