2016-08-20 14:00:08 -04:00
|
|
|
package WayofTime.bloodmagic.structures;
|
|
|
|
|
2018-03-01 18:23:56 -08:00
|
|
|
import WayofTime.bloodmagic.util.BMLog;
|
2016-08-20 14:00:08 -04:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
|
|
|
import net.minecraft.world.gen.structure.template.Template;
|
|
|
|
import net.minecraft.world.gen.structure.template.TemplateManager;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class DungeonStructure {
|
2016-08-21 13:17:04 -04:00
|
|
|
public ResourceLocation resource;
|
2016-08-20 14:00:08 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public DungeonStructure(ResourceLocation resource) {
|
2016-08-20 14:00:08 -04:00
|
|
|
this.resource = resource;
|
|
|
|
}
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public boolean placeStructureAtPosition(Random rand, PlacementSettings settings, WorldServer world, BlockPos pos) {
|
2016-08-20 14:00:08 -04:00
|
|
|
if (pos == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
MinecraftServer minecraftserver = world.getMinecraftServer();
|
|
|
|
TemplateManager templatemanager = world.getStructureTemplateManager();
|
|
|
|
|
2016-08-26 18:14:04 -04:00
|
|
|
Template template = templatemanager.getTemplate(minecraftserver, resource);
|
2016-08-20 14:00:08 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
if (template == null) {
|
2018-03-01 18:23:56 -08:00
|
|
|
BMLog.DEBUG.warn("Invalid template for location: " + resource);
|
2016-08-20 14:00:08 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// settings.func_189946_a(MathHelper.clamp_float(schema.integrity, 0.0F, 1.0F));
|
|
|
|
|
|
|
|
BlockPos offset = Template.transformedBlockPos(settings, new BlockPos(0, 0, 0));
|
|
|
|
BlockPos finalPos = pos.add(offset);
|
|
|
|
template.addBlocksToWorldChunk(world, finalPos, settings);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-08-20 17:16:07 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public DungeonStructure copy() {
|
2016-08-20 17:16:07 -04:00
|
|
|
return new DungeonStructure(resource);
|
|
|
|
}
|
2016-08-20 14:00:08 -04:00
|
|
|
}
|