Skip to content

Commit

Permalink
Implement some optional methods in ForgeWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Oct 1, 2018
1 parent aee011e commit 3e1c58c
Showing 1 changed file with 59 additions and 6 deletions.
Expand Up @@ -24,6 +24,7 @@
import com.google.common.io.Files;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
Expand All @@ -47,6 +48,8 @@
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockOldLeaf;
Expand Down Expand Up @@ -86,14 +89,14 @@
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.common.DimensionManager;

import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -351,25 +354,75 @@ public boolean generateTree(TreeType type, EditSession editSession, Vector posit
return generator != null && generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position));
}

@Override
public void checkLoadedChunk(Vector pt) {
getWorld().getChunkFromBlockCoords(ForgeAdapter.toBlockPos(pt));
}

@Override
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
fixLighting(chunks);
}

@Override
public void fixLighting(Iterable<BlockVector2D> chunks) {
World world = getWorld();
for (BlockVector2D chunk : chunks) {
world.getChunkFromChunkCoords(chunk.getBlockX(), chunk.getBlockZ()).resetRelightChecks();
}
}

@Override
public boolean playEffect(Vector position, int type, int data) {
getWorld().playEvent(type, ForgeAdapter.toBlockPos(position), data);
return true;
}

@Override
public WeatherType getWeather() {
// TODO Weather implementation
return null;
WorldInfo info = getWorld().getWorldInfo();
if (info.isThundering()) {
return WeatherTypes.THUNDER_STORM;
}
if (info.isRaining()) {
return WeatherTypes.RAIN;
}
return WeatherTypes.CLEAR;
}

@Override
public long getRemainingWeatherDuration() {
return 0;
WorldInfo info = getWorld().getWorldInfo();
if (info.isThundering()) {
return info.getThunderTime();
}
if (info.isRaining()) {
return info.getRainTime();
}
return info.getCleanWeatherTime();
}

@Override
public void setWeather(WeatherType weatherType) {

setWeather(weatherType, 0);
}

@Override
public void setWeather(WeatherType weatherType, long duration) {

WorldInfo info = getWorld().getWorldInfo();
if (WeatherTypes.THUNDER_STORM.equals(weatherType)) {
info.setCleanWeatherTime(0);
info.setThundering(true);
info.setThunderTime((int) duration);
} else if (WeatherTypes.RAIN.equals(weatherType)) {
info.setCleanWeatherTime(0);
info.setRaining(true);
info.setRainTime((int) duration);
} else if (WeatherTypes.CLEAR.equals(weatherType)) {
info.setRaining(false);
info.setThundering(false);
info.setCleanWeatherTime((int) duration);
}
}

@Override
Expand Down

0 comments on commit 3e1c58c

Please sign in to comment.