Bug fixes
This commit is contained in:
parent
70922ceae1
commit
08a8123b2e
13 changed files with 124 additions and 34 deletions
|
@ -15,11 +15,10 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.dimdev.dimdoors.DimDoors;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
|
@ -234,6 +233,8 @@ public class Schematic {
|
|||
// Place the schematic's blocks
|
||||
List<IBlockState> palette = schematic.pallette;
|
||||
int[][][] blockData = schematic.blockData;
|
||||
Set<Chunk> changedChunks = new HashSet<>();
|
||||
long start = System.currentTimeMillis();
|
||||
for (int x = 0; x < blockData.length; x++) {
|
||||
for (int y = 0; y < blockData[x].length; y++) {
|
||||
for (int z = 0; z < blockData[x][y].length; z++) {
|
||||
|
@ -250,10 +251,21 @@ public class Schematic {
|
|||
}
|
||||
if (storage != null) storage.set(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15, state);
|
||||
chunk.markDirty();
|
||||
changedChunks.add(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: we might need relight the chunks if they had already been generated before
|
||||
DimDoors.log.info("Setting block states took " + (System.currentTimeMillis() - start) + " ms");
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
// Relight changed chunks
|
||||
for (Chunk chunk : changedChunks) {
|
||||
chunk.setLightPopulated(false);
|
||||
chunk.resetRelightChecks();
|
||||
chunk.checkLight();
|
||||
}
|
||||
world.markBlockRangeForRenderUpdate(xBase, yBase, zBase, xBase + schematic.width, yBase + schematic.height, zBase + schematic.length);
|
||||
DimDoors.log.info("Relighting took " + (System.currentTimeMillis() - start) + " ms");
|
||||
|
||||
// Set TileEntity data
|
||||
for (NBTTagCompound tileEntityNBT : schematic.tileEntities) {
|
||||
|
@ -267,7 +279,7 @@ public class Schematic {
|
|||
|
||||
// Correct the position
|
||||
tileEntity.setWorld(world);
|
||||
tileEntity.setPos(pos); //correct the position
|
||||
tileEntity.setPos(pos);
|
||||
tileEntity.markDirty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ public abstract class CommonProxy {
|
|||
}
|
||||
|
||||
public void registerTileEntities() { // TODO: new registry system
|
||||
GameRegistry.registerTileEntity(TileEntityEntranceRift.class, "TileEntityEntranceRift");
|
||||
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "TileEntityFloatingRift");
|
||||
GameRegistry.registerTileEntity(TileEntityEntranceRift.class, "EntranceRift");
|
||||
GameRegistry.registerTileEntity(TileEntityFloatingRift.class, "FloatingRift");
|
||||
}
|
||||
|
||||
public abstract boolean isClient();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.dimdev.dimdoors.shared.blocks;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -134,7 +135,7 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
|
|||
TileEntityFloatingRift newRift = (TileEntityFloatingRift) world.getTileEntity(pos);
|
||||
newRift.copyFrom(rift);
|
||||
newRift.updateType();
|
||||
world.notifyBlockUpdate(rift.getPos(), state, world.getBlockState(pos), 0); // TODO: does this work?
|
||||
//world.notifyBlockUpdate(rift.getPos(), state, world.getBlockState(pos), 0); // TODO: does this work?
|
||||
} else {
|
||||
rift.unregister();
|
||||
}
|
||||
|
@ -143,6 +144,11 @@ public abstract class BlockDimensionalDoor extends BlockDoor implements IRiftPro
|
|||
// Let vanilla handle breaking the block. If we break it here, the rift we place will later be broken.
|
||||
@Override public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {}
|
||||
|
||||
@Override
|
||||
public EnumPushReaction getMobilityFlag(IBlockState state) {
|
||||
return EnumPushReaction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntityEntranceRift getRift(World world, BlockPos pos, IBlockState state) {
|
||||
if (state.getValue(BlockDoor.HALF) == EnumDoorHalf.LOWER) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dimdev.dimdoors.shared.blocks;
|
||||
|
||||
import net.minecraft.block.material.EnumPushReaction;
|
||||
import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -68,6 +69,12 @@ public abstract class BlockDimensionalTrapdoor extends BlockTrapDoor implements
|
|||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public EnumPushReaction getMobilityFlag(IBlockState state) {
|
||||
return EnumPushReaction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntityEntranceRift getRift(World world, BlockPos pos, IBlockState state) {
|
||||
return (TileEntityEntranceRift) world.getTileEntity(pos);
|
||||
|
|
|
@ -3,9 +3,6 @@ package org.dimdev.dimdoors.shared.blocks;
|
|||
import java.util.Random;
|
||||
|
||||
import org.dimdev.dimdoors.DimDoors;
|
||||
import org.dimdev.dimdoors.shared.VirtualLocation;
|
||||
import org.dimdev.ddutils.Location;
|
||||
import org.dimdev.ddutils.TeleportUtils;
|
||||
import org.dimdev.dimdoors.shared.world.limbodimension.LimboDecay;
|
||||
import org.dimdev.dimdoors.shared.world.limbodimension.WorldProviderLimbo;
|
||||
import lombok.Getter;
|
||||
|
@ -61,7 +58,6 @@ public class BlockFabric extends Block {
|
|||
setUnlocalizedName(ID);
|
||||
setCreativeTab(DimDoors.DIM_DOORS_CREATIVE_TAB);
|
||||
setHardness(0.1F);
|
||||
setLightLevel(1.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setDefaultState(getDefaultState().withProperty(TYPE, EnumType.REALITY));
|
||||
|
||||
|
@ -103,6 +99,11 @@ public class BlockFabric extends Block {
|
|||
}
|
||||
|
||||
// Block properties
|
||||
// TODO: Maybe we should split this into several classes, since different fabrics have very little in common other than the name:
|
||||
// 1. Reality/Altered
|
||||
// 2. Ancient/Altered Ancient
|
||||
// 3. Unravelled
|
||||
// 4. Eternal (which we should make a liquid)
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -124,6 +125,20 @@ public class BlockFabric extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getLightValue(IBlockState state) {
|
||||
switch (state.getValue(TYPE)) {
|
||||
case REALITY:
|
||||
case ALTERED:
|
||||
case ANCIENT:
|
||||
case ANCIENT_ALTERED:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return 0;
|
||||
|
|
|
@ -99,7 +99,7 @@ public class CommandPocket extends CommandBase {
|
|||
TileEntityRift entrance = (TileEntityRift) player.world.getTileEntity(pocket.getEntrance().getPos());
|
||||
entrance.teleportTo(player);
|
||||
} else {
|
||||
TeleportUtils.teleport(player, new Location(player.world, pocket.getOrigin().offset(EnumFacing.UP, 20)));
|
||||
TeleportUtils.teleport(player, new Location(player.world, pocket.getOrigin().add(30, 30, 30)));
|
||||
}
|
||||
} else {
|
||||
DimDoors.log.info("Not executing command /" + getName() + " because it wasn't sent by a player.");
|
||||
|
|
|
@ -135,7 +135,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
if (dest instanceof PocketExitDestination) {
|
||||
destIterator.remove();
|
||||
if (rift.isRegistered()) dest.unregister(rift);
|
||||
if (linkTo != null) rift.addAvailableLink(availableLink.toBuilder().build());
|
||||
if (availableLink != null) rift.addAvailableLink(availableLink.toBuilder().build());
|
||||
if (linkTo != null) destIterator.add(new WeightedRiftDestination(linkTo, wdest.getWeight(), wdest.getGroup(), oldDest));
|
||||
if (rift.isRegistered()) linkTo.register(rift);
|
||||
if (rift instanceof TileEntityEntranceRift && !rift.isAlwaysDelete()) {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package org.dimdev.dimdoors.shared.tools;
|
||||
|
||||
import org.dimdev.dimdoors.DimDoors;
|
||||
import org.dimdev.dimdoors.shared.blocks.BlockFabric;
|
||||
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
|
||||
import org.dimdev.ddutils.schem.Schematic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.dimdev.ddutils.schem.Schematic;
|
||||
import org.dimdev.dimdoors.DimDoors;
|
||||
import org.dimdev.dimdoors.shared.blocks.BlockFabric;
|
||||
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
public final class SchematicConverter {
|
||||
|
||||
private static final Map<String, IBlockState> stateMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
stateMap.put("dimdoors:Dimensional Door", ModBlocks.DIMENSIONAL_DOOR.getDefaultState());
|
||||
stateMap.put("dimdoors:Fabric of Reality", ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY));
|
||||
|
@ -40,7 +41,7 @@ public final class SchematicConverter {
|
|||
schematic.width = nbt.getShort("Width");
|
||||
schematic.height = nbt.getShort("Height");
|
||||
schematic.length = nbt.getShort("Length");
|
||||
schematic.offset = new int[]{0, 0, 0}; // TODO: center them
|
||||
schematic.offset = new int[]{0, 0, 0};
|
||||
|
||||
byte[] blockIntArray = nbt.getByteArray("Blocks");
|
||||
if (nbt.hasKey("Palette")) {
|
||||
|
@ -86,7 +87,8 @@ public final class SchematicConverter {
|
|||
block = ModBlocks.TRANSIENT_DIMENSIONAL_DOOR;
|
||||
break;
|
||||
}
|
||||
if (id != 0 && block.getRegistryName().toString().equals("minecraft:air")) throw new RuntimeException("Change conversion code!");
|
||||
if (id != 0 && block.getRegistryName().toString().equals("minecraft:air"))
|
||||
throw new RuntimeException("Change conversion code!");
|
||||
schematic.pallette.add(block.getDefaultState());
|
||||
palletteMap.put(id, currentPalletteIndex);
|
||||
blockIntArray[i] = currentPalletteIndex;
|
||||
|
@ -110,23 +112,60 @@ public final class SchematicConverter {
|
|||
blockInt = schematic.pallette.indexOf(additionalState);
|
||||
} else {
|
||||
schematic.pallette.add(additionalState);
|
||||
// DimDoors.log.info("New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
|
||||
//DimDoors.log.info("New blockstate detected. Original blockInt = " + blockInt + " and baseState is " + baseState);
|
||||
blockInt = schematic.pallette.size() - 1;
|
||||
}
|
||||
} else { // if this is ancient fabric
|
||||
// DimDoors.log.info("Non-default blockstate in palette detected. Original blockInt = " + blockInt + " and baseState is " + baseState.toString()); //@todo should only print a line on load of ancient fabric
|
||||
blockInt = schematic.pallette.indexOf(baseState);
|
||||
}
|
||||
assert blockInt >= 0;
|
||||
schematic.blockData[x][y][z] = blockInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
schematic.paletteMax = schematic.pallette.size() - 1;
|
||||
|
||||
NBTTagList tileEntitiesTagList = (NBTTagList) nbt.getTag("TileEntities");
|
||||
for (int i = 0; i < tileEntitiesTagList.tagCount(); i++) {
|
||||
NBTTagCompound tileEntityTagCompound = tileEntitiesTagList.getCompoundTagAt(i);
|
||||
schematic.tileEntities.add(tileEntityTagCompound);
|
||||
NBTTagList tileEntitiesNBT = (NBTTagList) nbt.getTag("TileEntities");
|
||||
for (int i = 0; i < tileEntitiesNBT.tagCount(); i++) {
|
||||
NBTTagCompound tileEntityNBT = tileEntitiesNBT.getCompoundTagAt(i);
|
||||
int x = tileEntityNBT.getInteger("x");
|
||||
int y = tileEntityNBT.getInteger("y");
|
||||
int z = tileEntityNBT.getInteger("z");
|
||||
switch (tileEntityNBT.getString("id")) {
|
||||
case "TileEntityDimDoor":
|
||||
tileEntityNBT = new NBTTagCompound();
|
||||
tileEntityNBT.setString("id", "EntranceRift");
|
||||
tileEntityNBT.setInteger("x", x);
|
||||
tileEntityNBT.setInteger("y", y);
|
||||
tileEntityNBT.setInteger("z", z);
|
||||
// TODO
|
||||
break;
|
||||
case "TileEntityRift":
|
||||
tileEntityNBT = new NBTTagCompound();
|
||||
tileEntityNBT.setString("id", "FloatingRift");
|
||||
tileEntityNBT.setInteger("x", x);
|
||||
tileEntityNBT.setInteger("y", y);
|
||||
tileEntityNBT.setInteger("z", z);
|
||||
// TODO
|
||||
break;
|
||||
case "Sign":
|
||||
DimDoors.log.info("Sign: "
|
||||
+ tileEntityNBT.getString("Text1") + "|"
|
||||
+ tileEntityNBT.getString("Text2") + "|"
|
||||
+ tileEntityNBT.getString("Text3") + "|"
|
||||
+ tileEntityNBT.getString("Text4"));
|
||||
tileEntityNBT.setString("Text1", "{\"text\":\"" + tileEntityNBT.getString("Text1") + "\"}");
|
||||
tileEntityNBT.setString("Text2", "{\"text\":\"" + tileEntityNBT.getString("Text2") + "\"}");
|
||||
tileEntityNBT.setString("Text3", "{\"text\":\"" + tileEntityNBT.getString("Text3") + "\"}");
|
||||
tileEntityNBT.setString("Text4", "{\"text\":\"" + tileEntityNBT.getString("Text4") + "\"}");
|
||||
break;
|
||||
case "Chest":
|
||||
break;
|
||||
default:
|
||||
DimDoors.log.info("TileEntity found: " + tileEntityNBT.getString("id"));
|
||||
break;
|
||||
}
|
||||
schematic.tileEntities.add(tileEntityNBT);
|
||||
}
|
||||
|
||||
return schematic;
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BiomeLimbo extends Biome {
|
|||
spawnableCreatureList.clear();
|
||||
spawnableWaterCreatureList.clear();
|
||||
spawnableCaveCreatureList.clear();
|
||||
spawnableMonsterList.add(new SpawnListEntry(EntityMonolith.class, 100, 4, 4));
|
||||
spawnableMonsterList.add(new SpawnListEntry(EntityMonolith.class, 100, 1, 1));
|
||||
|
||||
flowers.clear();
|
||||
|
||||
|
@ -66,4 +66,9 @@ public class BiomeLimbo extends Biome {
|
|||
public int getFoliageColorAtPos(BlockPos pos) {
|
||||
return getModdedBiomeFoliageColor(0x000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpawningChance() {
|
||||
return 0.5F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dimdev.dimdoors.shared.world.limbodimension;
|
||||
|
||||
import net.minecraft.world.WorldEntitySpawner;
|
||||
import org.dimdev.dimdoors.shared.blocks.BlockFabric;
|
||||
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
|
||||
import org.dimdev.dimdoors.shared.world.ModBiomes;
|
||||
|
@ -82,7 +83,9 @@ public class LimboGenerator implements IChunkGenerator {
|
|||
|
||||
@Override
|
||||
public void populate(int x, int z) {
|
||||
|
||||
// TODO: custom spawning?
|
||||
Biome biome = world.getBiome(new BlockPos(x * 16 + 16, 0, z * 16 + 16));
|
||||
WorldEntitySpawner.performWorldGenSpawning(world, biome, x * 16 + 8, z * 16 + 8, 16, 16, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +287,9 @@ public class LimboGenerator implements IChunkGenerator {
|
|||
|
||||
@Override
|
||||
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
|
||||
return new ArrayList<>();
|
||||
// TODO: custom spawning?
|
||||
Biome biome = world.getBiome(pos);
|
||||
return biome.getSpawnableList(creatureType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -37,8 +37,9 @@ public class WorldProviderLimbo extends WorldProvider {
|
|||
@Override
|
||||
protected void generateLightBrightnessTable() {
|
||||
for (int i = 0; i <= 15; ++i) {
|
||||
float var3 = 1.0F - i / 15.0F;
|
||||
lightBrightnessTable[i] = (0.0F + var3) / (var3 * 3.0F + 1.0F) * 1.0F * 3;
|
||||
//float var3 = 1.0F - i / 15.0F;
|
||||
//lightBrightnessTable[i] = (0.0F + var3) / (var3 * 3.0F + 1.0F) * 1.0F * 3;
|
||||
lightBrightnessTable[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BiomeBlank extends Biome {
|
|||
spawnableCreatureList.clear();
|
||||
spawnableWaterCreatureList.clear();
|
||||
spawnableCaveCreatureList.clear();
|
||||
if (monoliths) spawnableMonsterList.add(new SpawnListEntry(EntityMonolith.class, 100, 4, 4));
|
||||
//if (monoliths) spawnableMonsterList.add(new SpawnListEntry(EntityMonolith.class, 100, 4, 4));
|
||||
|
||||
flowers.clear();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public abstract class WorldProviderPocket extends WorldProvider {
|
|||
@Override
|
||||
public void init() {
|
||||
// TODO: save pocket registry nbt here? (see WorldProviderEnd)
|
||||
hasSkyLight = false; // TODO: this is only a temporary fix
|
||||
//hasSkyLight = false; // TODO: this is only a temporary fix
|
||||
generateLightBrightnessTable();
|
||||
DimDoors.proxy.setCloudRenderer(this, new CloudRenderBlank());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue