Skip to content

Commit

Permalink
remove a bunch of debug outs, fix the 'refuses to spawn in negative-x…
Browse files Browse the repository at this point in the history
…/negative-z chunks' issue and some minor cleanups
  • Loading branch information
dshadowwolf committed Mar 28, 2019
1 parent dbfaacd commit e942a2d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Expand Up @@ -3,6 +3,13 @@ def corePlugin = ''
buildscript {
repositories {
jcenter()
// maven {
// url 'http://maven.aliyun.com/nexus/content/groups/public/'
// }

// maven {
// url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
// }
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mcmoddev/orespawn/OreSpawn.java
Expand Up @@ -49,7 +49,7 @@ public class OreSpawn {
@Instance
public static OreSpawn instance;

public static final Logger LOGGER = LogManager.getFormatterLogger(Constants.MODID);
public static final Logger LOGGER = LogManager.getLogger(Constants.MODID);
public static final OS3API API = new OS3APIImpl();
static final EventHandlers eventHandlers = new EventHandlers();
public static final FeatureRegistry FEATURES = new FeatureRegistry();
Expand Down
31 changes: 17 additions & 14 deletions src/main/java/com/mcmoddev/orespawn/api/FeatureBase.java
Expand Up @@ -74,7 +74,7 @@ protected boolean spawn(final IBlockState oreBlock, final World world, final Blo
final BlockPos np = mungeFixYcoord(coord);

if (coord.getY() >= world.getHeight()) {
OreSpawn.LOGGER.warn("Asked to spawn %s above build limit at %s", oreBlock, coord);
OreSpawn.LOGGER.warn("Asked to spawn {} above build limit at {}", oreBlock, coord);
return false;
}

Expand All @@ -95,17 +95,20 @@ private boolean spawnOrCache(final World world, final BlockPos coord,
final OreSpawnBlockMatcher replacer, final IBlockState oreBlock,
final boolean cacheOverflow, final int dimension, final ISpawnEntry spawnData) {
if (world.isBlockLoaded(coord)) {
int m_x = coord.getX() - 1;
int p_x = coord.getX() + 1;
int x = coord.getX();
int m_z = coord.getZ() - 1;
int p_z = coord.getZ() + 1;
int z = coord.getZ();
int min_x = (((int)(x/16))*16)+1; // convert to ChunkPos
int max_x = min_x+30; // two chunks plus is 32 blocks, we are starting 1 block in and running to 1 block shy, thats 30 blocks
int min_z = (((int)(z/16))*16)+1; // convert to ChunkPos
int max_z = min_z+30; // two chunks plus is 32 blocks, we are starting 1 block in and running to 1 block shy, thats 30 blocks
if(m_x <= min_x || p_x >= max_x || m_z <= min_z || p_z >= max_z) {
int m_x = coord.getX();
int p_x = coord.getX();
int m_z = coord.getZ();
int p_z = coord.getZ();
int min_x = world.getChunk(coord).getPos().getXStart()+1; // convert to ChunkPos
int max_x = world.getChunk(coord).getPos().getXEnd()+15; // two chunks plus is 32 blocks, we are starting 1 block in and running to 1 block shy, thats 30 blocks
int min_z = world.getChunk(coord).getPos().getZStart()+1; // convert to ChunkPos
int max_z = world.getChunk(coord).getPos().getZEnd()+15; // two chunks plus is 32 blocks, we are starting 1 block in and running to 1 block shy, thats 30 blocks
boolean x_bad = false;
boolean z_bad = false;
if(m_x < min_x || p_x > max_x) x_bad = true;
if(m_z < min_z || p_z > max_z) z_bad = true;

if(x_bad || z_bad) {
if(cacheOverflow) {
cacheOverflowBlock(oreBlock, coord, dimension);
return true;
Expand Down Expand Up @@ -145,7 +148,7 @@ private void spawnNoCheck(final IBlockState oreBlock, final World world, final B
final BlockPos np = mungeFixYcoord(coord);

if (coord.getY() >= world.getHeight()) {
OreSpawn.LOGGER.warn("Asked to spawn %s above build limit at %s", oreBlock, coord);
OreSpawn.LOGGER.warn("Asked to spawn {} above build limit at {}", oreBlock, coord);
return;
}

Expand All @@ -154,7 +157,7 @@ private void spawnNoCheck(final IBlockState oreBlock, final World world, final B

private void cacheOverflowBlock(final IBlockState bs, final BlockPos coord,
final int dimension) {
final Vec3i chunkCoord = new Vec3i(coord.getX() >> 4, coord.getY() >> 4, dimension);
final Vec3i chunkCoord = new Vec3i(coord.getX() / 16, coord.getY() / 16, dimension);

if (overflowCache.containsKey(chunkCoord)) {
cacheOrder.addLast(chunkCoord);
Expand Down
Expand Up @@ -68,6 +68,7 @@ public void load(final FMLPreInitializationEvent event) {
try {
integration = Class.forName(clazz).asSubclass(IOreSpawnPlugin.class).newInstance();
final PluginData pd = new PluginData(modId, resourceBase, integration);
OreSpawn.LOGGER.fatal("Loading Integration For {}", modId);
dataStore.add(pd);
} catch (final Exception ex) {
OreSpawn.LOGGER.error("Couldn't load integrations for " + modId, ex);
Expand All @@ -89,9 +90,9 @@ public void scanResources(final PluginData pd) {

final String base = String.format(Locale.ENGLISH, "assets/%s/%s", pd.modId, pd.resourcePath);
final URL resURL = getClass().getClassLoader().getResource(base);

if (resURL == null) {
OreSpawn.LOGGER.warn("Unable to access file %s: got 'null' when trying to resolve it",
OreSpawn.LOGGER.warn("Unable to access file {}: got 'null' when trying to resolve it",
base);
return;
}
Expand Down
Expand Up @@ -150,7 +150,6 @@ public void loadFile(final Path file) {
JsonObject elements;
String rawJson;

com.mcmoddev.orespawn.OreSpawn.LOGGER.fatal("Loading file %s", file);

try {
rawJson = FileUtils.readFileToString(file.toFile(), Charset.defaultCharset());
Expand All @@ -167,8 +166,6 @@ public void loadFile(final Path file) {
final String entName = elem.getKey();
final JsonArray entries = elem.getValue().getAsJsonArray();
final List<IBlockState> blocks = new LinkedList<>();
com.mcmoddev.orespawn.OreSpawn.LOGGER.fatal("Loading replacement entry %s", entName);
// for (final JsonElement e : entries) {
entries.forEach( e -> {
final JsonObject asObj = e.getAsJsonObject();
final String blockName = asObj.get(Constants.ConfigNames.NAME).getAsString()
Expand Down
Expand Up @@ -60,7 +60,6 @@ public void generate(final World world, final IChunkGenerator chunkGenerator,
} else {
r = 0;
}

spawnOre(world, spawnData, new BlockPos(x, y, z), size + r);
}
} else if (random.nextFloat() < freq) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/mcmoddev/orespawn/json/OreSpawnReader.java
Expand Up @@ -178,7 +178,6 @@ private static void loadSingleEntry(final Entry<String, JsonElement> entry)
final ISpawnBuilder sb = OreSpawn.API.getSpawnBuilder();
final IFeatureBuilder fb = OreSpawn.API.getFeatureBuilder();
sb.setName(entry.getKey());

for (final Entry<String, JsonElement> ent : entry.getValue().getAsJsonObject().entrySet()) {
switch (ent.getKey()) {
case Constants.ConfigNames.RETROGEN:
Expand Down Expand Up @@ -267,7 +266,7 @@ private static void loadBlocks(ISpawnBuilder sb, Entry<String, JsonElement> ent)
sb.addBlock(block.create());
} else {
OreSpawn.LOGGER.error(
"Skipping value %s in blocks list as it is not the correct format",
"Skipping value {} in blocks list as it is not the correct format",
elem.toString());
}
}
Expand All @@ -293,7 +292,7 @@ private static void loadReplacements(IReplacementBuilder rb, Entry<String, JsonE
loadBlock(e.getAsJsonObject()).stream().forEach(rb::addEntry);
} else {
OreSpawn.LOGGER.error(
"Skipping value %s in replacements list as it is not the correct format",
"Skipping value {} in replacements list as it is not the correct format",
e.toString());
}
}
Expand Down
Expand Up @@ -24,7 +24,8 @@ public void generate(final Random random, final int chunkX, final int chunkZ, fi
OreSpawn.API.getSpawns(thisDim).stream().filter(ISpawnEntry::isEnabled)
.filter(sb -> !Config.getBoolean(Constants.RETROGEN_KEY)
|| (sb.isRetrogen() || Config.getBoolean(Constants.FORCE_RETROGEN_KEY)))
.forEach(spawn -> spawn.generate(random, world, chunkGenerator, chunkProvider,
.forEach(spawn ->
spawn.generate(random, world, chunkGenerator, chunkProvider,
new ChunkPos(chunkX, chunkZ)));
}
}

0 comments on commit e942a2d

Please sign in to comment.