-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
as requested by #196 this adds the same support for minecolonies as added for lostcities, some default configs could probably be used though
- Loading branch information
Showing
7 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package pokecube.compat.minecolonies; | ||
|
||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.ModList; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; | ||
|
||
@Mod.EventBusSubscriber | ||
public class Compat | ||
{ | ||
@SubscribeEvent | ||
public static void serverAboutToStart(final FMLServerAboutToStartEvent event) | ||
{ | ||
if (ModList.get().isLoaded("minecolonies")) Impl.register(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package pokecube.compat.minecolonies; | ||
|
||
import java.util.Locale; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.Sets; | ||
import com.minecolonies.api.IMinecoloniesAPI; | ||
import com.minecolonies.api.colony.IColony; | ||
import com.minecolonies.api.colony.buildings.IBuilding; | ||
|
||
import net.minecraft.util.math.AxisAlignedBB; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.IWorld; | ||
import net.minecraft.world.server.ServerChunkProvider; | ||
import pokecube.core.PokecubeCore; | ||
import pokecube.core.world.terrain.PokecubeTerrainChecker; | ||
import thut.api.maths.Vector3; | ||
import thut.api.terrain.BiomeType; | ||
import thut.api.terrain.TerrainSegment; | ||
import thut.api.terrain.TerrainSegment.ISubBiomeChecker; | ||
|
||
public class Impl | ||
{ | ||
private static boolean reged = false; | ||
|
||
private static IMinecoloniesAPI instance; | ||
private static Set<String> logged = Sets.newHashSet(); | ||
|
||
public static void register() | ||
{ | ||
if (Impl.reged) return; | ||
Impl.reged = true; | ||
TerrainSegment.defaultChecker = new TerrainChecker(TerrainSegment.defaultChecker); | ||
Impl.instance = IMinecoloniesAPI.getInstance(); | ||
} | ||
|
||
public static class TerrainChecker extends PokecubeTerrainChecker | ||
{ | ||
ISubBiomeChecker parent; | ||
|
||
public TerrainChecker(final ISubBiomeChecker parent) | ||
{ | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
public int getSubBiome(final IWorld world, final Vector3 v, final TerrainSegment segment, | ||
final boolean caveAdjusted) | ||
{ | ||
check: | ||
if (caveAdjusted) if (world.getChunkProvider() instanceof ServerChunkProvider) | ||
{ | ||
if (!Impl.instance.getColonyManager().isCoordinateInAnyColony(world.getWorld(), v.getPos())) | ||
break check; | ||
|
||
final IColony colony = Impl.instance.getColonyManager().getClosestColony(world.getWorld(), v.getPos()); | ||
final Vec3d vec = new Vec3d(v.x, v.y, v.z); | ||
for (final IBuilding b : colony.getBuildingManager().getBuildings().values()) | ||
{ | ||
String type = b.getSchematicName(); | ||
type = type.toLowerCase(Locale.ROOT); | ||
if (Impl.logged.add(type)) PokecubeCore.LOGGER.info("Minecolonies Structure: " + type); | ||
if (PokecubeTerrainChecker.structureSubbiomeMap.containsKey(type)) | ||
type = PokecubeTerrainChecker.structureSubbiomeMap.get(type); | ||
else continue; | ||
final AxisAlignedBB box = b.getTargetableArea(colony.getWorld()); | ||
if (box.contains(vec)) return BiomeType.getBiome(type, true).getType(); | ||
} | ||
} | ||
return this.parent.getSubBiome(world, v, segment, caveAdjusted); | ||
} | ||
} | ||
} |