Skip to content

Instantly share code, notes, and snippets.

@Lanse505
Last active July 4, 2020 18:22
Show Gist options
  • Save Lanse505/99f1114f71e5bde78d294dd211d013c2 to your computer and use it in GitHub Desktop.
Save Lanse505/99f1114f71e5bde78d294dd211d013c2 to your computer and use it in GitHub Desktop.
package net.minecraft.world.gen.feature.structure;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import java.util.List;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.SharedSeedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.jigsaw.EmptyJigsawPiece;
import net.minecraft.world.gen.feature.jigsaw.JigsawManager;
import net.minecraft.world.gen.feature.jigsaw.JigsawPattern;
import net.minecraft.world.gen.feature.jigsaw.JigsawPiece;
import net.minecraft.world.gen.feature.jigsaw.LegacySingleJigsawPiece;
import net.minecraft.world.gen.feature.jigsaw.ListJigsawPiece;
import net.minecraft.world.gen.feature.template.IntegrityProcessor;
import net.minecraft.world.gen.feature.template.TemplateManager;
public class PillagerOutpostPieces {
public static void func_215139_a(ChunkGenerator chunkGeneratorIn, TemplateManager templateManagerIn, BlockPos posIn, List<StructurePiece> structurePieces, SharedSeedRandom p_215139_4_) {
JigsawManager.func_236823_a_(new ResourceLocation("pillager_outpost/base_plates"), 7, PillagerOutpostPieces.PillageOutpost::new, chunkGeneratorIn, templateManagerIn, posIn, structurePieces, p_215139_4_, true, true);
}
public static void func_236999_a_() {
}
static {
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("pillager_outpost/base_plates"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new LegacySingleJigsawPiece("pillager_outpost/base_plate"), 1)), JigsawPattern.PlacementBehaviour.RIGID));
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("pillager_outpost/towers"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new ListJigsawPiece(ImmutableList.of(new LegacySingleJigsawPiece("pillager_outpost/watchtower"), new LegacySingleJigsawPiece("pillager_outpost/watchtower_overgrown", ImmutableList.of(new IntegrityProcessor(0.05F))))), 1)), JigsawPattern.PlacementBehaviour.RIGID));
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("pillager_outpost/feature_plates"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_plate"), 1)), JigsawPattern.PlacementBehaviour.TERRAIN_MATCHING));
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("pillager_outpost/features"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_cage1"), 1), Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_cage2"), 1), Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_logs"), 1), Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_tent1"), 1), Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_tent2"), 1), Pair.of(new LegacySingleJigsawPiece("pillager_outpost/feature_targets"), 1), Pair.of(EmptyJigsawPiece.INSTANCE, 6)), JigsawPattern.PlacementBehaviour.RIGID));
}
public static class PillageOutpost extends AbstractVillagePiece {
public PillageOutpost(TemplateManager templateManagerIn, JigsawPiece jigsawPieceIn, BlockPos posIn, int p_i50560_4_, Rotation rotationIn, MutableBoundingBox boundsIn) {
super(IStructurePieceType.PCP, templateManagerIn, jigsawPieceIn, posIn, p_i50560_4_, rotationIn, boundsIn);
}
public PillageOutpost(TemplateManager templateManagerIn, CompoundNBT nbt) {
super(templateManagerIn, nbt, IStructurePieceType.PCP);
}
}
}
package net.minecraft.world.gen.feature.structure;
import com.google.common.collect.Lists;
import com.mojang.serialization.Codec;
import java.util.List;
import net.minecraft.entity.EntityType;
import net.minecraft.util.SharedSeedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.template.TemplateManager;
public class PillagerOutpostStructure extends Structure<NoFeatureConfig> {
/** List of enemies that can spawn in the Pillage Outpost. */
private static final List<Biome.SpawnListEntry> PILLAGE_OUTPOST_ENEMIES = Lists.newArrayList(new Biome.SpawnListEntry(EntityType.PILLAGER, 1, 1, 1));
public PillagerOutpostStructure(Codec<NoFeatureConfig> p_i231977_1_) {
super(p_i231977_1_);
}
public List<Biome.SpawnListEntry> getSpawnList() {
return PILLAGE_OUTPOST_ENEMIES;
}
protected boolean func_230363_a_(ChunkGenerator p_230363_1_, BiomeProvider p_230363_2_, long p_230363_3_, SharedSeedRandom p_230363_5_, int p_230363_6_, int p_230363_7_, Biome p_230363_8_, ChunkPos p_230363_9_, NoFeatureConfig p_230363_10_) {
int i = p_230363_6_ >> 4;
int j = p_230363_7_ >> 4;
p_230363_5_.setSeed((long)(i ^ j << 4) ^ p_230363_3_);
p_230363_5_.nextInt();
if (p_230363_5_.nextInt(5) != 0) {
return false;
} else {
for(int k = p_230363_6_ - 10; k <= p_230363_6_ + 10; ++k) {
for(int l = p_230363_7_ - 10; l <= p_230363_7_ + 10; ++l) {
ChunkPos chunkpos = Structure.field_236381_q_.func_236392_a_(p_230363_1_.func_235957_b_().func_236197_a_(Structure.field_236381_q_), p_230363_3_, p_230363_5_, k, l);
if (k == chunkpos.x && l == chunkpos.z) {
return false;
}
}
}
return true;
}
}
public Structure.IStartFactory<NoFeatureConfig> getStartFactory() {
return PillagerOutpostStructure.Start::new;
}
public static class Start extends MarginedStructureStart<NoFeatureConfig> {
public Start(Structure<NoFeatureConfig> p_i225815_1_, int p_i225815_2_, int p_i225815_3_, MutableBoundingBox p_i225815_4_, int p_i225815_5_, long p_i225815_6_) {
super(p_i225815_1_, p_i225815_2_, p_i225815_3_, p_i225815_4_, p_i225815_5_, p_i225815_6_);
}
public void func_230364_a_(ChunkGenerator p_230364_1_, TemplateManager p_230364_2_, int p_230364_3_, int p_230364_4_, Biome p_230364_5_, NoFeatureConfig p_230364_6_) {
BlockPos blockpos = new BlockPos(p_230364_3_ * 16, 0, p_230364_4_ * 16);
PillagerOutpostPieces.func_215139_a(p_230364_1_, p_230364_2_, blockpos, this.components, this.rand);
this.recalculateStructureSize();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment