file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
LavaParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/LavaParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class LavaParticle extends GenericParticle {
public LavaParticle(Vector3 pos) {
super(pos, Particle.TYPE_LAVA);
}
}
| 305 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
EnchantmentTableParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/EnchantmentTableParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class EnchantmentTableParticle extends GenericParticle {
public EnchantmentTableParticle(Vector3 pos) {
super(pos, Particle.TYPE_ENCHANTMENT_TABLE);
}
}
| 342 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
RedstoneParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/RedstoneParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class RedstoneParticle extends GenericParticle {
public RedstoneParticle(Vector3 pos) {
this(pos, 1);
}
public RedstoneParticle(Vector3 pos, int lifetime) {
super(pos, Particle.TYPE_REDSTONE, lifetime);
}
}
| 413 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PortalParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/PortalParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class PortalParticle extends GenericParticle {
public PortalParticle(Vector3 pos) {
super(pos, Particle.TYPE_PORTAL);
}
}
| 311 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
HeartParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/HeartParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class HeartParticle extends GenericParticle {
public HeartParticle(Vector3 pos) {
this(pos, 0);
}
public HeartParticle(Vector3 pos, int scale) {
super(pos, Particle.TYPE_HEART, scale);
}
}
| 395 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
TerrainParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/TerrainParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.block.Block;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class TerrainParticle extends GenericParticle {
public TerrainParticle(Vector3 pos, Block block) {
super(pos, Particle.TYPE_TERRAIN, (block.getDamage() << 8) | block.getId());
}
}
| 399 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
DestroyBlockParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/DestroyBlockParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.block.Block;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class DestroyBlockParticle extends Particle {
protected final int data;
public DestroyBlockParticle(Vector3 pos, Block block) {
super(pos.x, pos.y, pos.z);
this.data = block.getId() | (block.getDamage() << 8);
}
@Override
public DataPacket[] encode() {
LevelEventPacket pk = new LevelEventPacket();
pk.evid = LevelEventPacket.EVENT_PARTICLE_DESTROY;
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.data = this.data;
return new DataPacket[]{pk};
}
}
| 874 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
ItemBreakParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/ItemBreakParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.item.Item;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class ItemBreakParticle extends GenericParticle {
public ItemBreakParticle(Vector3 pos, Item item) {
super(pos, Particle.TYPE_ITEM_BREAK, (item.getId() << 16) | item.getDamage());
}
}
| 401 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
EntityFlameParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/EntityFlameParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class EntityFlameParticle extends GenericParticle {
public EntityFlameParticle(Vector3 pos) {
super(pos, Particle.TYPE_MOB_FLAME);
}
}
| 324 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
HappyVillagerParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/HappyVillagerParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class HappyVillagerParticle extends GenericParticle {
public HappyVillagerParticle(Vector3 pos) {
super(pos, Particle.TYPE_VILLAGER_HAPPY);
}
}
| 333 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
MobSpawnParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/MobSpawnParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class MobSpawnParticle extends Particle {
protected final int width;
protected final int height;
public MobSpawnParticle(Vector3 pos, float width, float height) {
super(pos.x, pos.y, pos.z);
this.width = (int) width;
this.height = (int) height;
}
@Override
public DataPacket[] encode() {
LevelEventPacket packet = new LevelEventPacket();
packet.evid = LevelEventPacket.EVENT_PARTICLE_SPAWN;
packet.x = (float) this.x;
packet.y = (float) this.y;
packet.z = (float) this.z;
packet.data = (this.width & 0xff) + ((this.height & 0xff) << 8);
return new DataPacket[]{packet};
}
}
| 957 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
HugeExplodeSeedParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/HugeExplodeSeedParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class HugeExplodeSeedParticle extends GenericParticle {
public HugeExplodeSeedParticle(Vector3 pos) {
super(pos, Particle.TYPE_HUGE_EXPLODE_SEED);
}
}
| 340 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PunchBlockParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/PunchBlockParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.block.Block;
import cn.nukkit.math.BlockFace;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
public class PunchBlockParticle extends Particle {
protected final int data;
public PunchBlockParticle(Vector3 pos, Block block, BlockFace face) {
this(pos, block.getId(), block.getDamage(), face);
}
public PunchBlockParticle(Vector3 pos, int blockId, int blockDamage, BlockFace face) {
super(pos.x, pos.y, pos.z);
this.data = blockId | (blockDamage << 8) | (face.getIndex() << 16);
}
@Override
public DataPacket[] encode() {
LevelEventPacket pk = new LevelEventPacket();
pk.evid = LevelEventPacket.EVENT_PARTICLE_PUNCH_BLOCK;
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.data = this.data;
return new DataPacket[]{pk};
}
}
| 995 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GenericParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/GenericParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class GenericParticle extends Particle {
protected int id = 0;
protected final int data;
public GenericParticle(Vector3 pos, int id) {
this(pos, id, 0);
}
public GenericParticle(Vector3 pos, int id, int data) {
super(pos.x, pos.y, pos.z);
this.id = id;
this.data = data;
}
@Override
public DataPacket[] encode() {
LevelEventPacket pk = new LevelEventPacket();
pk.evid = (short) (LevelEventPacket.EVENT_ADD_PARTICLE_MASK | this.id);
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.data = this.data;
return new DataPacket[]{pk};
}
}
| 956 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SmokeParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/SmokeParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class SmokeParticle extends GenericParticle {
public SmokeParticle(Vector3 pos) {
this(pos, 0);
}
public SmokeParticle(Vector3 pos, int scale) {
super(pos, Particle.TYPE_SMOKE, scale);
}
}
| 395 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
LavaDripParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/LavaDripParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class LavaDripParticle extends GenericParticle {
public LavaDripParticle(Vector3 pos) {
super(pos, Particle.TYPE_DRIP_LAVA);
}
}
| 318 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
InkParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/InkParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class InkParticle extends GenericParticle {
public InkParticle(Vector3 pos) {
this(pos, 0);
}
public InkParticle(Vector3 pos, int scale) {
super(pos, Particle.TYPE_INK, scale);
}
}
| 388 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
WaterDripParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/WaterDripParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class WaterDripParticle extends GenericParticle {
public WaterDripParticle(Vector3 pos) {
super(pos, Particle.TYPE_DRIP_WATER);
}
}
| 321 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
AngryVillagerParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/AngryVillagerParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class AngryVillagerParticle extends GenericParticle {
public AngryVillagerParticle(Vector3 pos) {
super(pos, Particle.TYPE_VILLAGER_ANGRY);
}
}
| 333 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
CriticalParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/CriticalParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class CriticalParticle extends GenericParticle {
public CriticalParticle(Vector3 pos) {
this(pos, 2);
}
public CriticalParticle(Vector3 pos, int scale) {
super(pos, Particle.TYPE_CRITICAL, scale);
}
}
| 407 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SporeParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/SporeParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class SporeParticle extends GenericParticle {
public SporeParticle(Vector3 pos) {
super(pos, Particle.TYPE_TOWN_AURA);
}
}
| 312 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BlockForceFieldParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/BlockForceFieldParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
public class BlockForceFieldParticle extends GenericParticle {
public BlockForceFieldParticle(Vector3 pos) {
this(pos, 0);
}
public BlockForceFieldParticle(Vector3 pos, int scale) {
super(pos, Particle.TYPE_BLOCK_FORCE_FIELD);
}
}
| 331 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
RainSplashParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/RainSplashParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class RainSplashParticle extends GenericParticle {
public RainSplashParticle(Vector3 pos) {
super(pos, Particle.TYPE_RAIN_SPLASH);
}
}
| 324 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
EnchantParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/EnchantParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class EnchantParticle extends GenericParticle {
public EnchantParticle(Vector3 pos) {
super(pos, Particle.TYPE_MOB_SPELL);
}
}
| 316 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
ExplodeParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/ExplodeParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class ExplodeParticle extends GenericParticle {
public ExplodeParticle(Vector3 pos) {
super(pos, Particle.TYPE_EXPLODE);
}
}
| 314 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
FloatingTextParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/FloatingTextParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.entity.Entity;
import cn.nukkit.entity.data.EntityMetadata;
import cn.nukkit.item.Item;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.AddPlayerPacket;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.RemoveEntityPacket;
import java.util.ArrayList;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class FloatingTextParticle extends Particle {
protected String text;
protected String title;
protected long entityId = -1;
protected boolean invisible = false;
protected EntityMetadata metadata = new EntityMetadata();
public FloatingTextParticle(Vector3 pos, String text) {
this(pos, text, "");
}
public FloatingTextParticle(Vector3 pos, String text, String title) {
super(pos.x, pos.y, pos.z);
this.text = text;
this.title = title;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isInvisible() {
return invisible;
}
public void setInvisible(boolean invisible) {
this.invisible = invisible;
}
public void setInvisible() {
this.setInvisible(true);
}
@Override
public DataPacket[] encode() {
ArrayList<DataPacket> packets = new ArrayList<>();
if (this.entityId == -1) {
this.entityId = 1095216660480L + ThreadLocalRandom.current().nextLong(0, 0x7fffffffL);
} else {
RemoveEntityPacket pk = new RemoveEntityPacket();
pk.eid = this.entityId;
packets.add(pk);
}
if (!this.invisible) {
AddPlayerPacket pk = new AddPlayerPacket();
pk.uuid = UUID.randomUUID();
pk.username = "";
pk.entityUniqueId = this.entityId;
pk.entityRuntimeId = this.entityId;
pk.x = (float) this.x;
pk.y = (float) (this.y - 0.75);
pk.z = (float) this.z;
pk.speedX = 0;
pk.speedY = 0;
pk.speedZ = 0;
pk.yaw = 0;
pk.pitch = 0;
long flags = (
(1L << Entity.DATA_FLAG_CAN_SHOW_NAMETAG) |
(1L << Entity.DATA_FLAG_ALWAYS_SHOW_NAMETAG) |
(1L << Entity.DATA_FLAG_IMMOBILE)
);
pk.metadata = new EntityMetadata()
.putLong(Entity.DATA_FLAGS, flags)
.putString(Entity.DATA_NAMETAG, this.title + (!this.text.isEmpty() ? "\n" + this.text : ""))
.putLong(Entity.DATA_LEAD_HOLDER_EID,-1)
.putFloat(Entity.DATA_SCALE, 0.01f); //zero causes problems on debug builds?
pk.item = Item.get(Item.AIR);
packets.add(pk);
}
return packets.stream().toArray(DataPacket[]::new);
}
} | 3,198 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
InstantSpellParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/InstantSpellParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.utils.BlockColor;
/**
* Created on 2016/1/4 by xtypr.
* Package cn.nukkit.level.particle in project nukkit .
*/
public class InstantSpellParticle extends SpellParticle {
protected int data;
public InstantSpellParticle(Vector3 pos) {
this(pos, 0);
}
public InstantSpellParticle(Vector3 pos, int data) {
super(pos, data);
}
public InstantSpellParticle(Vector3 pos, BlockColor blockColor) {
//alpha is ignored
this(pos, blockColor.getRed(), blockColor.getGreen(), blockColor.getBlue());
}
public InstantSpellParticle(Vector3 pos, int r, int g, int b) {
//this 0x01 is the only difference between instant spell and non-instant one
super(pos, r, g, b, 0x01);
}
}
| 834 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
InstantEnchantParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/InstantEnchantParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class InstantEnchantParticle extends GenericParticle {
public InstantEnchantParticle(Vector3 pos) {
super(pos, Particle.TYPE_MOB_SPELL_INSTANTANEOUS);
}
}
| 344 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
HugeExplodeParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/HugeExplodeParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class HugeExplodeParticle extends GenericParticle {
public HugeExplodeParticle(Vector3 pos) {
super(pos, Particle.TYPE_HUGE_EXPLODE);
}
}
| 327 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SpellParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/SpellParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
import cn.nukkit.utils.BlockColor;
/**
* Created on 2015/12/27 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
* The name "spell" comes from minecraft wiki.
*/
public class SpellParticle extends Particle {
protected final int data;
public SpellParticle(Vector3 pos) {
this(pos, 0);
}
public SpellParticle(Vector3 pos, int data) {
super(pos.x, pos.y, pos.z);
this.data = data;
}
public SpellParticle(Vector3 pos, BlockColor blockColor) {
//alpha is ignored
this(pos, blockColor.getRed(), blockColor.getGreen(), blockColor.getBlue());
}
public SpellParticle(Vector3 pos, int r, int g, int b) {
this(pos, r, g, b, 0x00);
}
protected SpellParticle(Vector3 pos, int r, int g, int b, int a) {
this(pos, ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff));
}
@Override
public DataPacket[] encode() {
LevelEventPacket pk = new LevelEventPacket();
pk.evid = LevelEventPacket.EVENT_PARTICLE_SPLASH;
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.data = this.data;
return new DataPacket[]{pk};
}
}
| 1,396 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BoneMealParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/BoneMealParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.LevelEventPacket;
/**
* Created by CreeperFace on 15.4.2017.
*/
public class BoneMealParticle extends Particle {
private Vector3 position;
public BoneMealParticle(Vector3 pos) {
super(pos.x, pos.y, pos.z);
}
@Override
public DataPacket[] encode() {
LevelEventPacket pk = new LevelEventPacket();
pk.evid = LevelEventPacket.EVENT_PARTICLE_BONEMEAL;
pk.x = (float) this.x;
pk.y = (float) this.y;
pk.z = (float) this.z;
pk.data = 0;
return new DataPacket[]{pk};
}
}
| 703 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
DustParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/DustParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.utils.BlockColor;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class DustParticle extends GenericParticle {
public DustParticle(Vector3 pos, BlockColor blockColor) {
this(pos, blockColor.getRed(), blockColor.getGreen(), blockColor.getBlue(), blockColor.getAlpha());
}
public DustParticle(Vector3 pos, int r, int g, int b) {
this(pos, r, g, b, 255);
}
public DustParticle(Vector3 pos, int r, int g, int b, int a) {
super(pos, Particle.TYPE_DUST, ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff));
}
}
| 720 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SplashParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/SplashParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class SplashParticle extends GenericParticle {
public SplashParticle(Vector3 pos) {
super(pos, Particle.TYPE_WATER_SPLASH);
}
}
| 317 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BubbleParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/BubbleParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class BubbleParticle extends GenericParticle {
public BubbleParticle(Vector3 pos) {
super(pos, Particle.TYPE_BUBBLE);
}
}
| 311 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
WaterParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/WaterParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class WaterParticle extends GenericParticle {
public WaterParticle(Vector3 pos) {
super(pos, Particle.TYPE_WATER_WAKE);
}
}
| 313 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Particle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/Particle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
import cn.nukkit.network.protocol.DataPacket;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class Particle extends Vector3 {
public static final int TYPE_BUBBLE = 1;
public static final int TYPE_CRITICAL = 2;
public static final int TYPE_BLOCK_FORCE_FIELD = 3;
public static final int TYPE_SMOKE = 4;
public static final int TYPE_EXPLODE = 5;
public static final int TYPE_EVAPORATION = 6;
public static final int TYPE_FLAME = 7;
public static final int TYPE_LAVA = 8;
public static final int TYPE_LARGE_SMOKE = 9;
public static final int TYPE_REDSTONE = 10;
public static final int TYPE_RISING_RED_DUST = 11;
public static final int TYPE_ITEM_BREAK = 12;
public static final int TYPE_SNOWBALL_POOF = 13;
public static final int TYPE_HUGE_EXPLODE = 14;
public static final int TYPE_HUGE_EXPLODE_SEED = 15;
public static final int TYPE_MOB_FLAME = 16;
public static final int TYPE_HEART = 17;
public static final int TYPE_TERRAIN = 18;
public static final int TYPE_SUSPENDED_TOWN = 19, TYPE_TOWN_AURA = 19;
public static final int TYPE_PORTAL = 20;
public static final int TYPE_SPLASH = 21, TYPE_WATER_SPLASH = 21;
public static final int TYPE_WATER_WAKE = 22;
public static final int TYPE_DRIP_WATER = 23;
public static final int TYPE_DRIP_LAVA = 24;
public static final int TYPE_FALLING_DUST = 25, TYPE_DUST = 25;
public static final int TYPE_MOB_SPELL = 26;
public static final int TYPE_MOB_SPELL_AMBIENT = 27;
public static final int TYPE_MOB_SPELL_INSTANTANEOUS = 28;
public static final int TYPE_INK = 29;
public static final int TYPE_SLIME = 30;
public static final int TYPE_RAIN_SPLASH = 31;
public static final int TYPE_VILLAGER_ANGRY = 32;
public static final int TYPE_VILLAGER_HAPPY = 33;
public static final int TYPE_ENCHANTMENT_TABLE = 34;
public static final int TYPE_TRACKING_EMITTER = 35;
public static final int TYPE_NOTE = 36;
public static final int TYPE_WITCH_SPELL = 37;
public static final int TYPE_CARROT = 38;
//39 unknown
public static final int TYPE_END_ROD = 40;
public static final int TYPE_DRAGONS_BREATH = 41;
public Particle() {
super(0, 0, 0);
}
public Particle(double x) {
super(x, 0, 0);
}
public Particle(double x, double y) {
super(x, y, 0);
}
public Particle(double x, double y, double z) {
super(x, y, z);
}
abstract public DataPacket[] encode();
}
| 2,608 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
FlameParticle.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/particle/FlameParticle.java | package cn.nukkit.level.particle;
import cn.nukkit.math.Vector3;
/**
* Created on 2015/11/21 by xtypr.
* Package cn.nukkit.level.particle in project Nukkit .
*/
public class FlameParticle extends GenericParticle {
public FlameParticle(Vector3 pos) {
super(pos, Particle.TYPE_FLAME);
}
}
| 308 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Generator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/Generator.java | package cn.nukkit.level.generator;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.Level;
import cn.nukkit.level.generator.noise.Noise;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import java.util.HashMap;
import java.util.Map;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class Generator {
public static final int TYPE_OLD = 0;
public static final int TYPE_INFINITE = 1;
public static final int TYPE_FLAT = 2;
public static final int TYPE_NETHER = 3;
public abstract int getId();
public int getDimension() {
return Level.DIMENSION_OVERWORLD;
}
private static final Map<String, Class<? extends Generator>> nameList = new HashMap<>();
private static final Map<Integer, Class<? extends Generator>> typeList = new HashMap<>();
public static boolean addGenerator(Class<? extends Generator> clazz, String name, int type) {
name = name.toLowerCase();
if (clazz != null && !Generator.nameList.containsKey(name)) {
Generator.nameList.put(name, clazz);
if (!Generator.typeList.containsKey(type)) {
Generator.typeList.put(type, clazz);
}
return true;
}
return false;
}
public static String[] getGeneratorList() {
String[] keys = new String[Generator.nameList.size()];
return Generator.nameList.keySet().toArray(keys);
}
public static Class<? extends Generator> getGenerator(String name) {
name = name.toLowerCase();
if (Generator.nameList.containsKey(name)) {
return Generator.nameList.get(name);
}
return Normal.class;
}
public static Class<? extends Generator> getGenerator(int type) {
if (Generator.typeList.containsKey(type)) {
return Generator.typeList.get(type);
}
return Normal.class;
}
public static String getGeneratorName(Class<? extends Generator> c) {
for (String key : Generator.nameList.keySet()) {
if (Generator.nameList.get(key).equals(c)) {
return key;
}
}
return "unknown";
}
public static int getGeneratorType(Class<? extends Generator> c) {
for (int key : Generator.typeList.keySet()) {
if (Generator.typeList.get(key).equals(c)) {
return key;
}
}
return Generator.TYPE_INFINITE;
}
public static double[] getFastNoise1D(Noise noise, int xSize, int samplingRate, int x, int y, int z) {
if (samplingRate == 0) {
throw new IllegalArgumentException("samplingRate cannot be 0");
}
if (xSize % samplingRate != 0) {
throw new IllegalArgumentException("xSize % samplingRate must return 0");
}
double[] noiseArray = new double[xSize + 1];
for (int xx = 0; xx <= xSize; xx += samplingRate) {
noiseArray[xx] = noise.noise3D(xx + x, y, z);
}
for (int xx = 0; xx < xSize; ++xx) {
if (xx % samplingRate != 0) {
int nx = xx / samplingRate * samplingRate;
noiseArray[nx] = Noise.linearLerp(xx, nx, nx + samplingRate, noiseArray[nx], noiseArray[nx + samplingRate]);
}
}
return noiseArray;
}
public static double[][] getFastNoise2D(Noise noise, int xSize, int zSize, int samplingRate, int x, int y, int z, int xZoom, int zZoom) {
if (samplingRate == 0) {
throw new IllegalArgumentException("samplingRate cannot be 0");
}
if (xSize % samplingRate != 0) {
throw new IllegalArgumentException("xSize % samplingRate must return 0");
}
if (zSize % samplingRate != 0) {
throw new IllegalArgumentException("zSize % samplingRate must return 0");
}
double[][] noiseArray = new double[xSize + 1][zSize + 1];
for (int xx = 0; xx <= xSize; xx += samplingRate) {
noiseArray[xx] = new double[zSize + 1];
for (int zz = 0; zz <= zSize; zz += samplingRate) {
noiseArray[xx][zz] = noise.noise3D((x + xx) >> xZoom, y, (z + zz) >> zZoom);
}
}
for (int xx = 0; xx < xSize; ++xx) {
if (xx % samplingRate != 0) {
noiseArray[xx] = new double[zSize + 1];
}
for (int zz = 0; zz < zSize; ++zz) {
if (xx % samplingRate != 0 || zz % samplingRate != 0) {
int nx = xx / samplingRate * samplingRate;
int nz = zz / samplingRate * samplingRate;
noiseArray[xx][zz] = Noise.bilinearLerp(
xx, zz, noiseArray[nx][nz], noiseArray[nx][nz + samplingRate],
noiseArray[nx + samplingRate][nz], noiseArray[nx + samplingRate][nz + samplingRate],
nx, nx + samplingRate, nz, nz + samplingRate
);
}
}
}
return noiseArray;
}
public static double[][] getFastNoise2D(Noise noise, int xSize, int zSize, int samplingRate, int x, int y, int z) {
return Generator.getFastNoise2D(noise, xSize, zSize, samplingRate, x, y, z, 0, 0);
}
public static double[][][] getFastNoise3D(Noise noise, int xSize, int ySize, int zSize, int xSamplingRate, int ySamplingRate, int zSamplingRate, int x, int y, int z) {
if (xSamplingRate == 0) {
throw new IllegalArgumentException("xSamplingRate cannot be 0");
}
if (zSamplingRate == 0) {
throw new IllegalArgumentException("zSamplingRate cannot be 0");
}
if (ySamplingRate == 0) {
throw new IllegalArgumentException("ySamplingRate cannot be 0");
}
if (xSize % xSamplingRate != 0) {
throw new IllegalArgumentException("xSize % xSamplingRate must return 0");
}
if (zSize % zSamplingRate != 0) {
throw new IllegalArgumentException("zSize % zSamplingRate must return 0");
}
if (ySize % ySamplingRate != 0) {
throw new IllegalArgumentException("ySize % ySamplingRate must return 0");
}
double[][][] noiseArray = new double[xSize + 1][zSize + 1][ySize + 1];
for (int xx = 0; xx <= xSize; xx += xSamplingRate) {
for (int zz = 0; zz <= zSize; zz += zSamplingRate) {
for (int yy = 0; yy <= ySize; yy += ySamplingRate) {
noiseArray[xx][zz][yy] = noise.noise3D(x + xx, y + yy, z + zz, true);
}
}
}
for (int xx = 0; xx < xSize; ++xx) {
for (int zz = 0; zz < zSize; ++zz) {
for (int yy = 0; yy < ySize; ++yy) {
if (xx % xSamplingRate != 0 || zz % zSamplingRate != 0 || yy % ySamplingRate != 0) {
int nx = xx / xSamplingRate * xSamplingRate;
int ny = yy / ySamplingRate * ySamplingRate;
int nz = zz / zSamplingRate * zSamplingRate;
int nnx = nx + xSamplingRate;
int nny = ny + ySamplingRate;
int nnz = nz + zSamplingRate;
double dx1 = ((double) (nnx - xx) / (double) (nnx - nx));
double dx2 = ((double) (xx - nx) / (double) (nnx - nx));
double dy1 = ((double) (nny - yy) / (double) (nny - ny));
double dy2 = ((double) (yy - ny) / (double) (nny - ny));
noiseArray[xx][zz][yy] = ((double) (nnz - zz) / (double) (nnz - nz)) * (
dy1 * (
dx1 * noiseArray[nx][nz][ny] + dx2 * noiseArray[nnx][nz][ny]
) + dy2 * (
dx1 * noiseArray[nx][nz][nny] + dx2 * noiseArray[nnx][nz][nny]
)
) + ((double) (zz - nz) / (double) (nnz - nz)) * (
dy1 * (
dx1 * noiseArray[nx][nnz][ny] + dx2 * noiseArray[nnx][nnz][ny]
) + dy2 * (
dx1 * noiseArray[nx][nnz][nny] + dx2 * noiseArray[nnx][nnz][nny]
)
);
}
}
}
}
return noiseArray;
}
public abstract void init(ChunkManager level, NukkitRandom random);
public abstract void generateChunk(int chunkX, int chunkZ);
public abstract void populateChunk(int chunkX, int chunkZ);
public abstract Map<String, Object> getSettings();
public abstract String getName();
public abstract Vector3 getSpawn();
public abstract ChunkManager getChunkManager();
}
| 8,955 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Nether.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/Nether.java | package cn.nukkit.level.generator;
import cn.nukkit.block.*;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.Level;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.level.generator.noise.Simplex;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.level.generator.populator.*;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import java.util.*;
public class Nether extends Generator {
private ChunkManager level;
/**
* @var Random
*/
private NukkitRandom nukkitRandom;
private Random random;
private double waterHeight = 32;
private double emptyHeight = 64;
private double emptyAmplitude = 1;
private double density = 0.5;
private double bedrockDepth = 5;
private final List<Populator> populators = new ArrayList<>();
private List<Populator> generationPopulators = new ArrayList<>();
private long localSeed1;
private long localSeed2;
private Simplex noiseBase;
public Nether() {
this(new HashMap<>());
}
public Nether(Map<String, Object> options) {
//Nothing here. Just used for future update.
}
@Override
public int getId() {
return Generator.TYPE_NETHER;
}
@Override
public int getDimension() {
return Level.DIMENSION_NETHER;
}
@Override
public String getName() {
return "nether";
}
@Override
public Map<String, Object> getSettings() {
return new HashMap<>();
}
@Override
public ChunkManager getChunkManager() {
return level;
}
@Override
public void init(ChunkManager level, NukkitRandom random) {
this.level = level;
this.nukkitRandom = random;
this.random = new Random();
this.nukkitRandom.setSeed(this.level.getSeed());
this.noiseBase = new Simplex(this.nukkitRandom, 4, 1 / 4f, 1 / 64f);
this.nukkitRandom.setSeed(this.level.getSeed());
this.localSeed1 = this.random.nextLong();
this.localSeed2 = this.random.nextLong();
PopulatorOre ores = new PopulatorOre(Block.NETHERRACK);
ores.setOreTypes(new OreType[]{
new OreType(new BlockOreQuartz(), 20, 16, 0, 128),
new OreType(new BlockSoulSand(), 5, 64, 0, 128),
new OreType(new BlockGravel(), 5, 64, 0, 128),
new OreType(new BlockLava(), 1, 16, 0, (int) this.waterHeight),
});
this.populators.add(ores);
this.populators.add(new PopulatorGlowStone());
PopulatorGroundFire groundFire = new PopulatorGroundFire();
groundFire.setBaseAmount(1);
groundFire.setRandomAmount(1);
this.populators.add(groundFire);
PopulatorLava lava = new PopulatorLava();
lava.setBaseAmount(0);
lava.setRandomAmount(2);
this.populators.add(lava);
}
@Override
public void generateChunk(int chunkX, int chunkZ) {
this.nukkitRandom.setSeed(chunkX * localSeed1 ^ chunkZ * localSeed2 ^ this.level.getSeed());
double[][][] noise = Generator.getFastNoise3D(this.noiseBase, 16, 128, 16, 4, 8, 4, chunkX * 16, 0, chunkZ * 16);
FullChunk chunk = this.level.getChunk(chunkX, chunkZ);
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
Biome biome = Biome.getBiome(Biome.HELL);
chunk.setBiomeId(x, z, Biome.HELL);
int biomecolor = biome.getColor();
chunk.setBiomeColor(x, z, (biomecolor >> 16), (biomecolor >> 8) & 0xff, (biomecolor & 0xff));
chunk.setBlockId(x, 0, z, Block.BEDROCK);
chunk.setBlockId(x, 127, z, Block.BEDROCK);
for (int y = 1; y <= bedrockDepth; y++) {
if (nukkitRandom.nextRange(1, 5) == 1) {
chunk.setBlockId(x, y, z, Block.BEDROCK);
chunk.setBlockId(x, 127 - y, z, Block.BEDROCK);
}
}
for (int y = 1; y < 127; ++y) {
double noiseValue = (Math.abs(this.emptyHeight - y) / this.emptyHeight) * this.emptyAmplitude - noise[x][z][y];
noiseValue -= 1 - this.density;
if (noiseValue > 0) {
chunk.setBlockId(x, y, z, Block.NETHERRACK);
} else if (y <= this.waterHeight) {
chunk.setBlockId(x, y, z, Block.STILL_LAVA);
chunk.setBlockLight(x, y + 1, z, 15);
}
}
}
}
for (Populator populator : this.generationPopulators) {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom);
}
}
@Override
public void populateChunk(int chunkX, int chunkZ) {
this.nukkitRandom.setSeed(0xdeadbeef ^ (chunkX << 8) ^ chunkZ ^ this.level.getSeed());
for (Populator populator : this.populators) {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom);
}
FullChunk chunk = this.level.getChunk(chunkX, chunkZ);
Biome biome = Biome.getBiome(chunk.getBiomeId(7, 7));
biome.populateChunk(this.level, chunkX, chunkZ, this.nukkitRandom);
}
public Vector3 getSpawn() {
return new Vector3(0, 64, 0);
}
} | 5,412 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Normal.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/Normal.java | package cn.nukkit.level.generator;
import cn.nukkit.block.*;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.level.generator.biome.BiomeSelector;
import cn.nukkit.level.generator.noise.Simplex;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.level.generator.populator.*;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import java.util.*;
/**
* This generator was written by Creeperface and Nycuro
* <p>
* The following classes are theirs and are intended for NUKKIT USAGE and should not be copied/translated to other software
* such as BukkitPE, ClearSky, Genisys , Pocketmine-MP
* <p>
* Normal.java
* MushroomPopulator.java
* DarkOakTreePopulator.java
* JungleBigTreePopulator.java
* JungleTreePopulaotr.java
* SavannaTreePopulator.java
* SwampTreePopulator.java
* BasicPopulator.java
* MesaBiome.java
* JungleBiome.java
* SavannaBiome.java
* RoofedForestBiome.java
* RoofedForestMBiome.java
* MushroomIsland.java
* TreeGenerator.java
* HugeTreesGenerator.java
* <p>
* Created by CreeperFace on 26. 10. 2016.
*/
public class Normal extends Generator {
/**
* biome IDs
*/
public static final int JUNGLE = 21;
public static final int SAVANNA = 35;
public static final int ROOFED_FOREST = 29;
public static final int ROOFED_FOREST_M = 157;
public static final int MUSHROOM_ISLAND = 14;
public static final int SWAMP = 6;
public static final int OCEAN = 0;
public static final int PLAINS = 1;
public static final int DESERT = 2;
public static final int FOREST = 4;
public static final int TAIGA = 5;
public static final int RIVER = 7;
public static final int ICE_PLAINS = 12;
public static final int BEACH = 16;
public static final int BIRCH_FOREST = 27;
public static final int MAX_BIOMES = 256;
@Override
public int getId() {
return TYPE_INFINITE;
}
private final List<Populator> populators = new ArrayList<>();
private ChunkManager level;
private Random random;
private NukkitRandom nukkitRandom;
private long localSeed1;
private long localSeed2;
private final List<Populator> generationPopulators = new ArrayList<>();
private Simplex noiseSeaFloor;
private Simplex noiseLand;
private Simplex noiseMountains;
private Simplex noiseBaseGround;
private Simplex noiseRiver;
private BiomeSelector selector;
private int heightOffset;
private final int seaHeight = 64;
private final int seaFloorHeight = 48;
private final int beathStartHeight = 60;
private final int beathStopHeight = 64;
private final int bedrockDepth = 5;
private final int seaFloorGenerateRange = 5;
private final int landHeightRange = 18;
private final int mountainHeight = 13;
private final int basegroundHeight = 3;
private int waterColor = 16777215;
//private boolean enableSnow; Coming soon
protected float rainfall = 0.5F;
protected float temperature = 0.5F;
protected int grassColor = 0;
public Normal() {
this(new HashMap<>());
}
public Normal(Map<String, Object> options) {
//Nothing here. Just used for future update.
}
@Override
public ChunkManager getChunkManager() {
return level;
}
@Override
public String getName() {
return "normal";
}
@Override
public Map<String, Object> getSettings() {
return new HashMap<>();
}
public Biome pickBiome(int x, int z) {
long hash = x * 2345803 ^ z * 9236449 ^ this.level.getSeed();
hash *= hash + 223;
long xNoise = hash >> 20 & 3;
long zNoise = hash >> 22 & 3;
if (xNoise == 3) {
xNoise = 1;
}
if (zNoise == 3) {
zNoise = 1;
}
return this.selector.pickBiome(x + xNoise - 1, z + zNoise - 1);
}
@Override
public void init(ChunkManager level, NukkitRandom random) {
this.level = level;
this.nukkitRandom = random;
this.random = new Random();
this.nukkitRandom.setSeed(this.level.getSeed());
this.localSeed1 = this.random.nextLong();
this.localSeed2 = this.random.nextLong();
this.noiseSeaFloor = new Simplex(this.nukkitRandom, 1F, 1F / 8F, 1F / 64F);
this.noiseLand = new Simplex(this.nukkitRandom, 2F, 1F / 8F, 1F / 512F);
this.noiseMountains = new Simplex(this.nukkitRandom, 4F, 1F, 1F / 500F);
this.noiseBaseGround = new Simplex(this.nukkitRandom, 4F, 1F / 4F, 1F / 64F);
this.noiseRiver = new Simplex(this.nukkitRandom, 2F, 1F, 1F / 512F);
this.nukkitRandom.setSeed(this.level.getSeed());
this.selector = new BiomeSelector(this.nukkitRandom, Biome.getBiome(Biome.FOREST));
this.heightOffset = random.nextRange(-5, 3);
this.selector.addBiome(Biome.getBiome(OCEAN));
this.selector.addBiome(Biome.getBiome(PLAINS));
this.selector.addBiome(Biome.getBiome(DESERT));
this.selector.addBiome(Biome.getBiome(FOREST));
this.selector.addBiome(Biome.getBiome(TAIGA));
this.selector.addBiome(Biome.getBiome(RIVER));
this.selector.addBiome(Biome.getBiome(ICE_PLAINS));
this.selector.addBiome(Biome.getBiome(BIRCH_FOREST));
this.selector.addBiome(Biome.getBiome(JUNGLE));
this.selector.addBiome(Biome.getBiome(SAVANNA));
this.selector.addBiome(Biome.getBiome(ROOFED_FOREST));
this.selector.addBiome(Biome.getBiome(ROOFED_FOREST_M));
this.selector.addBiome(Biome.getBiome(MUSHROOM_ISLAND));
this.selector.addBiome(Biome.getBiome(SWAMP));
this.selector.recalculate();
PopulatorCaves caves = new PopulatorCaves();
this.populators.add(caves);
PopulatorRavines ravines = new PopulatorRavines();
this.populators.add(ravines);
// PopulatorDungeon dungeons = new PopulatorDungeon();
// this.populators.add(dungeons);
PopulatorGroundCover cover = new PopulatorGroundCover();
this.generationPopulators.add(cover);
PopulatorOre ores = new PopulatorOre();
ores.setOreTypes(new OreType[]{
new OreType(new BlockOreCoal(), 20, 17, 0, 128),
new OreType(new BlockOreIron(), 20, 9, 0, 64),
new OreType(new BlockOreRedstone(), 8, 8, 0, 16),
new OreType(new BlockOreLapis(), 1, 7, 0, 16),
new OreType(new BlockOreGold(), 2, 9, 0, 32),
new OreType(new BlockOreDiamond(), 1, 8, 0, 16),
new OreType(new BlockDirt(), 10, 33, 0, 128),
new OreType(new BlockGravel(), 8, 33, 0, 128),
new OreType(new BlockStone(BlockStone.GRANITE), 10, 33, 0, 80),
new OreType(new BlockStone(BlockStone.DIORITE), 10, 33, 0, 80),
new OreType(new BlockStone(BlockStone.ANDESITE), 10, 33, 0, 80)
});
this.populators.add(ores);
}
@Override
public void generateChunk(int chunkX, int chunkZ) {
this.nukkitRandom.setSeed(chunkX * localSeed1 ^ chunkZ * localSeed2 ^ this.level.getSeed());
double[][] seaFloorNoise = Generator.getFastNoise2D(this.noiseSeaFloor, 16, 16, 4, chunkX * 16, 0, chunkZ * 16);
double[][] landNoise = Generator.getFastNoise2D(this.noiseLand, 16, 16, 4, chunkX * 16, 0, chunkZ * 16);
double[][] mountainNoise = Generator.getFastNoise2D(this.noiseMountains, 16, 16, 4, chunkX * 16, 0, chunkZ * 16);
double[][] baseNoise = Generator.getFastNoise2D(this.noiseBaseGround, 16, 16, 4, chunkX * 16, 0, chunkZ * 16);
double[][] riverNoise = Generator.getFastNoise2D(this.noiseRiver, 16, 16, 4, chunkX * 16, 0, chunkZ * 16);
FullChunk chunk = this.level.getChunk(chunkX, chunkZ);
for (int genx = 0; genx < 16; genx++) {
for (int genz = 0; genz < 16; genz++) {
Biome biome;
boolean canBaseGround = false;
boolean canRiver = true;
//using a quadratic function which smooth the world
//y = (2.956x)^2 - 0.6, (0 <= x <= 2)
double landHeightNoise = landNoise[genx][genz] + 1F;
landHeightNoise *= 2.956;
landHeightNoise = landHeightNoise * landHeightNoise;
landHeightNoise = landHeightNoise - 0.6F;
landHeightNoise = landHeightNoise > 0 ? landHeightNoise : 0;
//generate mountains
double mountainHeightGenerate = mountainNoise[genx][genz] - 0.2F;
mountainHeightGenerate = mountainHeightGenerate > 0 ? mountainHeightGenerate : 0;
int mountainGenerate = (int) (mountainHeight * mountainHeightGenerate);
int landHeightGenerate = (int) (landHeightRange * landHeightNoise);
if (landHeightGenerate > landHeightRange) {
if (landHeightGenerate > landHeightRange) {
canBaseGround = true;
}
landHeightGenerate = landHeightRange;
}
int genyHeight = seaFloorHeight + landHeightGenerate;
genyHeight += mountainGenerate;
//prepare for generate ocean, desert, and land
if (genyHeight < beathStartHeight) {
if (genyHeight < beathStartHeight - 5) {
genyHeight += (int) (seaFloorGenerateRange * seaFloorNoise[genx][genz]);
}
biome = Biome.getBiome(Biome.OCEAN);
if (genyHeight < seaFloorHeight - seaFloorGenerateRange) {
genyHeight = seaFloorHeight;
}
canRiver = false;
} else if (genyHeight <= beathStopHeight && genyHeight >= beathStartHeight) {
biome = Biome.getBiome(Biome.BEACH);
} else {
biome = this.pickBiome(chunkX * 16 + genx, chunkZ * 16 + genz);
if (canBaseGround) {
int baseGroundHeight = (int) (landHeightRange * landHeightNoise) - landHeightRange;
int baseGroundHeight2 = (int) (basegroundHeight * (baseNoise[genx][genz] + 1F));
if (baseGroundHeight2 > baseGroundHeight) baseGroundHeight2 = baseGroundHeight;
if (baseGroundHeight2 > mountainGenerate)
baseGroundHeight2 = baseGroundHeight2 - mountainGenerate;
else baseGroundHeight2 = 0;
genyHeight += baseGroundHeight2;
}
}
if (canRiver && genyHeight <= seaHeight - 5) {
canRiver = false;
}
//generate river
if (canRiver) {
double riverGenerate = riverNoise[genx][genz];
if (riverGenerate > -0.25F && riverGenerate < 0.25F) {
riverGenerate = riverGenerate > 0 ? riverGenerate : -riverGenerate;
riverGenerate = 0.25F - riverGenerate;
//y=x^2 * 4 - 0.0000001
riverGenerate = riverGenerate * riverGenerate * 4F;
//smooth again
riverGenerate = riverGenerate - 0.0000001F;
riverGenerate = riverGenerate > 0 ? riverGenerate : 0;
genyHeight -= riverGenerate * 64;
if (genyHeight < seaHeight) {
biome = Biome.getBiome(Biome.RIVER);
//to generate river floor
if (genyHeight <= seaHeight - 8) {
int genyHeight1 = seaHeight - 9 + (int) (basegroundHeight * (baseNoise[genx][genz] + 1F));
int genyHeight2 = genyHeight < seaHeight - 7 ? seaHeight - 7 : genyHeight;
genyHeight = genyHeight1 > genyHeight2 ? genyHeight1 : genyHeight2;
}
}
}
}
chunk.setBiomeId(genx, genz, biome.getId());
//biome color
//todo: smooth chunk color
int biomecolor = biome.getColor();
chunk.setBiomeColor(genx, genz, (biomecolor >> 16), (biomecolor >> 8) & 0xff, (biomecolor & 0xff));
//generating
int generateHeight = genyHeight > seaHeight ? genyHeight : seaHeight;
for (int geny = 0; geny <= generateHeight; geny++) {
if (geny <= bedrockDepth && (geny == 0 || nukkitRandom.nextRange(1, 5) == 1)) {
chunk.setBlock(genx, geny, genz, Block.BEDROCK);
} else if (geny > genyHeight) {
if ((biome.getId() == Biome.ICE_PLAINS || biome.getId() == Biome.TAIGA) && geny == seaHeight) {
chunk.setBlock(genx, geny, genz, Block.ICE);
} else {
chunk.setBlock(genx, geny, genz, Block.STILL_WATER);
}
} else {
chunk.setBlock(genx, geny, genz, Block.STONE);
}
}
}
}
//populator chunk
for (Populator populator : this.generationPopulators) {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom);
}
}
@Override
public void populateChunk(int chunkX, int chunkZ) {
this.nukkitRandom.setSeed(0xdeadbeef ^ (chunkX << 8) ^ chunkZ ^ this.level.getSeed());
for (Populator populator : this.populators) {
populator.populate(this.level, chunkX, chunkZ, this.nukkitRandom);
}
FullChunk chunk = this.level.getChunk(chunkX, chunkZ);
Biome biome = Biome.getBiome(chunk.getBiomeId(7, 7));
biome.populateChunk(this.level, chunkX, chunkZ, this.nukkitRandom);
}
@Override
public Vector3 getSpawn() {
return new Vector3(127.5, 256, 127.5);
}
} | 14,347 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Flat.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/Flat.java | package cn.nukkit.level.generator;
import cn.nukkit.Server;
import cn.nukkit.block.*;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.level.generator.populator.PopulatorOre;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class Flat extends Generator {
@Override
public int getId() {
return TYPE_FLAT;
}
private ChunkManager level;
private NukkitRandom random;
private final List<Populator> populators = new ArrayList<>();
private int[][] structure;
private final Map<String, Object> options;
private int floorLevel;
private String preset;
private boolean init = false;
private int biome;
@Override
public ChunkManager getChunkManager() {
return level;
}
@Override
public Map<String, Object> getSettings() {
return this.options;
}
@Override
public String getName() {
return "flat";
}
public Flat() {
this(new HashMap<>());
}
public Flat(Map<String, Object> options) {
this.preset = "2;7,2x3,2;1;";
this.options = options;
if (this.options.containsKey("decoration")) {
PopulatorOre ores = new PopulatorOre();
ores.setOreTypes(new OreType[]{
new OreType(new BlockOreCoal(), 20, 16, 0, 128),
new OreType(new BlockOreIron(), 20, 8, 0, 64),
new OreType(new BlockOreRedstone(), 8, 7, 0, 16),
new OreType(new BlockOreLapis(), 1, 6, 0, 32),
new OreType(new BlockOreGold(), 2, 8, 0, 32),
new OreType(new BlockOreDiamond(), 1, 7, 0, 16),
new OreType(new BlockDirt(), 20, 32, 0, 128),
new OreType(new BlockGravel(), 20, 16, 0, 128),
});
this.populators.add(ores);
}
}
protected void parsePreset(String preset, int chunkX, int chunkZ) {
try {
this.preset = preset;
String[] presetArray = preset.split(";");
int version = Integer.valueOf(presetArray[0]);
String blocks = presetArray.length > 1 ? presetArray[1] : "";
this.biome = presetArray.length > 2 ? Integer.valueOf(presetArray[2]) : 1;
String options = presetArray.length > 3 ? presetArray[1] : "";
this.structure = new int[256][];
int y = 0;
for (String block : blocks.split(",")) {
int id, meta = 0, cnt = 1;
if (Pattern.matches("^[0-9]{1,3}x[0-9]$", block)) {
//AxB
String[] s = block.split("x");
cnt = Integer.valueOf(s[0]);
id = Integer.valueOf(s[1]);
} else if (Pattern.matches("^[0-9]{1,3}:[0-9]{0,2}$", block)) {
//A:B
String[] s = block.split(":");
id = Integer.valueOf(s[0]);
meta = Integer.valueOf(s[1]);
} else if (Pattern.matches("^[0-9]{1,3}$", block)) {
//A
id = Integer.valueOf(block);
} else {
continue;
}
int cY = y;
y += cnt;
if (y > 0xFF) {
y = 0xFF;
}
for (; cY < y; ++cY) {
this.structure[cY] = new int[]{id, meta};
}
}
this.floorLevel = y;
for (; y <= 0xFF; ++y) {
this.structure[y] = new int[]{0, 0};
}
for (String option : options.split(",")) {
if (Pattern.matches("^[0-9a-z_]+$", option)) {
this.options.put(option, true);
} else if (Pattern.matches("^[0-9a-z_]+\\([0-9a-z_ =]+\\)$", option)) {
String name = option.substring(0, option.indexOf("("));
String extra = option.substring(option.indexOf("(") + 1, option.indexOf(")"));
Map<String, Float> map = new HashMap<>();
for (String kv : extra.split(" ")) {
String[] data = kv.split("=");
map.put(data[0], Float.valueOf(data[1]));
}
this.options.put(name, map);
}
}
} catch (Exception e) {
Server.getInstance().getLogger().error("error while parsing the preset", e);
throw new RuntimeException(e);
}
}
@Override
public void init(ChunkManager level, NukkitRandom random) {
this.level = level;
this.random = random;
}
@Override
public void generateChunk(int chunkX, int chunkZ) {
if (!this.init) {
init = true;
if (this.options.containsKey("preset") && !"".equals(this.options.get("preset"))) {
this.parsePreset((String) this.options.get("preset"), chunkX, chunkZ);
} else {
this.parsePreset(this.preset, chunkX, chunkZ);
}
}
FullChunk chunk = this.level.getChunk(chunkX, chunkZ);
this.generateChunk(chunk);
}
private void generateChunk(FullChunk chunk) {
chunk.setGenerated();
int c = Biome.getBiome(biome).getColor();
int R = c >> 16;
int G = (c >> 8) & 0xff;
int B = c & 0xff;
for (int Z = 0; Z < 16; ++Z) {
for (int X = 0; X < 16; ++X) {
chunk.setBiomeId(X, Z, biome);
chunk.setBiomeColor(X, Z, R, G, B);
for (int y = 0; y < 256; ++y) {
int k = this.structure[y][0];
int l = this.structure[y][1];
chunk.setBlock(X, y, Z, this.structure[y][0], this.structure[y][1]);
}
}
}
}
@Override
public void populateChunk(int chunkX, int chunkZ) {
this.random.setSeed(0xdeadbeef ^ (chunkX << 8) ^ chunkZ ^ this.level.getSeed());
for (Populator populator : this.populators) {
populator.populate(this.level, chunkX, chunkZ, this.random);
}
}
@Override
public Vector3 getSpawn() {
return new Vector3(128, this.floorLevel, 128);
}
}
| 6,723 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Simplex.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/noise/Simplex.java | package cn.nukkit.level.generator.noise;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class Simplex extends Perlin {
protected static double SQRT_3;
protected static double SQRT_5;
protected static double F2;
protected static double G2;
protected static double G22;
protected static double F3;
protected static double G3;
protected static double F4;
protected static double G4;
protected static double G42;
protected static double G43;
protected static double G44;
protected static int[][] grad4 = {{0, 1, 1, 1}, {0, 1, 1, -1}, {0, 1, -1, 1}, {0, 1, -1, -1},
{0, -1, 1, 1}, {0, -1, 1, -1}, {0, -1, -1, 1}, {0, -1, -1, -1},
{1, 0, 1, 1}, {1, 0, 1, -1}, {1, 0, -1, 1}, {1, 0, -1, -1},
{-1, 0, 1, 1}, {-1, 0, 1, -1}, {-1, 0, -1, 1}, {-1, 0, -1, -1},
{1, 1, 0, 1}, {1, 1, 0, -1}, {1, -1, 0, 1}, {1, -1, 0, -1},
{-1, 1, 0, 1}, {-1, 1, 0, -1}, {-1, -1, 0, 1}, {-1, -1, 0, -1},
{1, 1, 1, 0}, {1, 1, -1, 0}, {1, -1, 1, 0}, {1, -1, -1, 0},
{-1, 1, 1, 0}, {-1, 1, -1, 0}, {-1, -1, 1, 0}, {-1, -1, -1, 0}};
protected static int[][] simplex = {
{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 0, 0, 0}, {0, 2, 3, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 2, 3, 0},
{0, 2, 1, 3}, {0, 0, 0, 0}, {0, 3, 1, 2}, {0, 3, 2, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 3, 2, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{1, 2, 0, 3}, {0, 0, 0, 0}, {1, 3, 0, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {2, 3, 0, 1}, {2, 3, 1, 0},
{1, 0, 2, 3}, {1, 0, 3, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {2, 0, 3, 1}, {0, 0, 0, 0}, {2, 1, 3, 0},
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{2, 0, 1, 3}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {3, 0, 1, 2}, {3, 0, 2, 1}, {0, 0, 0, 0}, {3, 1, 2, 0},
{2, 1, 0, 3}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {3, 1, 0, 2}, {0, 0, 0, 0}, {3, 2, 0, 1}, {3, 2, 1, 0}};
protected final double offsetW;
public Simplex(NukkitRandom random, double octaves, double persistence) {
super(random, octaves, persistence);
this.offsetW = random.nextDouble() * 256;
SQRT_3 = Math.sqrt(3);
SQRT_5 = Math.sqrt(5);
F2 = 0.5 * (SQRT_3 - 1);
G2 = (3 - SQRT_3) / 6;
G22 = G2 * 2.0 - 1;
F3 = 1.0 / 3.0;
G3 = 1.0 / 6.0;
F4 = (SQRT_5 - 1.0) / 4.0;
G4 = (5.0 - SQRT_5) / 20.0;
G42 = G4 * 2.0;
G43 = G4 * 3.0;
G44 = G4 * 4.0 - 1.0;
}
public Simplex(NukkitRandom random, double octaves, double persistence, double expansion) {
super(random, octaves, persistence, expansion);
this.offsetW = random.nextDouble() * 256;
SQRT_3 = Math.sqrt(3);
SQRT_5 = Math.sqrt(5);
F2 = 0.5 * (SQRT_3 - 1);
G2 = (3 - SQRT_3) / 6;
G22 = G2 * 2.0 - 1;
F3 = 1.0 / 3.0;
G3 = 1.0 / 6.0;
F4 = (SQRT_5 - 1.0) / 4.0;
G4 = (5.0 - SQRT_5) / 20.0;
G42 = G4 * 2.0;
G43 = G4 * 3.0;
G44 = G4 * 4.0 - 1.0;
}
protected static double dot2D(int[] g, double x, double y) {
return g[0] * x + g[1] * y;
}
protected static double dot3D(int[] g, double x, double y, double z) {
return g[0] * x + g[1] * y + g[2] * z;
}
protected static double dot4D(int[] g, double x, double y, double z, double w) {
return g[0] * x + g[1] * y + g[2] * z + g[3] * w;
}
@Override
public double getNoise3D(double x, double y, double z) {
x += this.offsetX;
y += this.offsetY;
z += this.offsetZ;
// Skew the input space to determine which simplex cell we're in
double s = (x + y + z) * F3; // Very nice and simple skew factor for 3D
int i = (int) (x + s);
int j = (int) (y + s);
int k = (int) (z + s);
double t = (i + j + k) * G3;
// Unskew the cell origin back to (x,y,z) space
double x0 = x - (i - t); // The x,y,z distances from the cell origin
double y0 = y - (j - t);
double z0 = z - (k - t);
// For the 3D case, the simplex shape is a slightly irregular tetrahedron.
int i1 = 0;
int j1 = 0;
int k1 = 0;
int i2 = 0;
int j2 = 0;
int k2 = 0;
// Determine which simplex we are in.
if (x0 >= y0) {
if (y0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
} // X Y Z order
else if (x0 >= z0) {
i1 = 1;
j1 = 0;
k1 = 0;
i2 = 1;
j2 = 0;
k2 = 1;
} // X Z Y order
else {
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 1;
j2 = 0;
k2 = 1;
}
// Z X Y order
} else { // x0<y0
if (y0 < z0) {
i1 = 0;
j1 = 0;
k1 = 1;
i2 = 0;
j2 = 1;
k2 = 1;
} // Z Y X order
else if (x0 < z0) {
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 0;
j2 = 1;
k2 = 1;
} // Y Z X order
else {
i1 = 0;
j1 = 1;
k1 = 0;
i2 = 1;
j2 = 1;
k2 = 0;
}
// Y X Z order
}
// A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
// a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
// a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
// c = 1/6.
double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords
double y1 = y0 - j1 + G3;
double z1 = z0 - k1 + G3;
double x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords
double y2 = y0 - j2 + 2.0 * G3;
double z2 = z0 - k2 + 2.0 * G3;
double x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords
double y3 = y0 - 1.0 + 3.0 * G3;
double z3 = z0 - 1.0 + 3.0 * G3;
// Work out the hashed gradient indices of the four simplex corners
int ii = i & 255;
int jj = j & 255;
int kk = k & 255;
double n = 0;
// Calculate the contribution from the four corners
double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0;
if (t0 > 0) {
int[] gi0 = grad3[this.perm[ii + this.perm[jj + this.perm[kk]]] % 12];
n += t0 * t0 * t0 * t0 * (gi0[0] * x0 + gi0[1] * y0 + gi0[2] * z0);
}
double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1;
if (t1 > 0) {
int[] gi1 = grad3[this.perm[ii + i1 + this.perm[jj + j1 + this.perm[kk + k1]]] % 12];
n += t1 * t1 * t1 * t1 * (gi1[0] * x1 + gi1[1] * y1 + gi1[2] * z1);
}
double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2;
if (t2 > 0) {
int[] gi2 = grad3[this.perm[ii + i2 + this.perm[jj + j2 + this.perm[kk + k2]]] % 12];
n += t2 * t2 * t2 * t2 * (gi2[0] * x2 + gi2[1] * y2 + gi2[2] * z2);
}
double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3;
if (t3 > 0) {
int[] gi3 = grad3[this.perm[ii + 1 + this.perm[jj + 1 + this.perm[kk + 1]]] % 12];
n += t3 * t3 * t3 * t3 * (gi3[0] * x3 + gi3[1] * y3 + gi3[2] * z3);
}
// Add contributions from each corner to get the noise value.
// The result is scaled to stay just inside [-1,1]
return 32.0 * n;
}
@Override
public double getNoise2D(double x, double y) {
x += this.offsetX;
y += this.offsetY;
// Skew the input space to determine which simplex cell we're in
double s = (x + y) * F2; // Hairy factor for 2D
int i = (int) (x + s);
int j = (int) (y + s);
double t = (i + j) * G2;
// Unskew the cell origin back to (x,y) space
double x0 = x - (i - t); // The x,y distances from the cell origin
double y0 = y - (j - t);
// For the 2D case, the simplex shape is an equilateral triangle.
int i1 = 0;
int j1 = 0;
// Determine which simplex we are in.
if (x0 > y0) {
i1 = 1;
j1 = 0;
} // lower triangle, XY order: (0,0).(1,0).(1,1)
else {
i1 = 0;
j1 = 1;
}
// upper triangle, YX order: (0,0).(0,1).(1,1)
// A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
// a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
// c = (3-sqrt(3))/6
double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
double y1 = y0 - j1 + G2;
double x2 = x0 + G22; // Offsets for last corner in (x,y) unskewed coords
double y2 = y0 + G22;
// Work out the hashed gradient indices of the three simplex corners
int ii = i & 255;
int jj = j & 255;
double n = 0;
// Calculate the contribution from the three corners
double t0 = 0.5 - x0 * x0 - y0 * y0;
if (t0 > 0) {
int[] gi0 = grad3[this.perm[ii + this.perm[jj]] % 12];
n += t0 * t0 * t0 * t0 * (gi0[0] * x0 + gi0[1] * y0); // (x,y) of grad3 used for 2D gradient
}
double t1 = 0.5 - x1 * x1 - y1 * y1;
if (t1 > 0) {
int[] gi1 = grad3[this.perm[ii + i1 + this.perm[jj + j1]] % 12];
n += t1 * t1 * t1 * t1 * (gi1[0] * x1 + gi1[1] * y1);
}
double t2 = 0.5 - x2 * x2 - y2 * y2;
if (t2 > 0) {
int[] gi2 = grad3[this.perm[ii + 1 + this.perm[jj + 1]] % 12];
n += t2 * t2 * t2 * t2 * (gi2[0] * x2 + gi2[1] * y2);
}
// Add contributions from each corner to get the noise value.
// The result is scaled to return values in the interval [-1,1].
return 70.0 * n;
}
}
| 10,506 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Noise.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/noise/Noise.java | package cn.nukkit.level.generator.noise;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class Noise {
protected int[] perm;
protected double offsetX = 0;
protected double offsetY = 0;
protected double offsetZ = 0;
protected double octaves = 8;
protected double persistence;
protected double expansion;
public static int floor(double x) {
return x >= 0 ? (int) x : (int) (x - 1);
}
public static double fade(double x) {
return x * x * x * (x * (x * 6 - 15) + 10);
}
public static double lerp(double x, double y, double z) {
return y + x * (z - y);
}
public static double linearLerp(double x, double x1, double x2, double q0, double q1) {
return ((x2 - x) / (x2 - x1)) * q0 + ((x - x1) / (x2 - x1)) * q1;
}
public static double bilinearLerp(double x, double y, double q00, double q01, double q10, double q11, double x1, double x2, double y1, double y2) {
double dx1 = ((x2 - x) / (x2 - x1));
double dx2 = ((x - x1) / (x2 - x1));
return ((y2 - y) / (y2 - y1)) * (
dx1 * q00 + dx2 * q10
) + ((y - y1) / (y2 - y1)) * (
dx1 * q01 + dx2 * q11
);
}
public static double trilinearLerp(double x, double y, double z, double q000, double q001, double q010, double q011, double q100, double q101, double q110, double q111, double x1, double x2, double y1, double y2, double z1, double z2) {
double dx1 = ((x2 - x) / (x2 - x1));
double dx2 = ((x - x1) / (x2 - x1));
double dy1 = ((y2 - y) / (y2 - y1));
double dy2 = ((y - y1) / (y2 - y1));
return ((z2 - z) / (z2 - z1)) * (
dy1 * (
dx1 * q000 + dx2 * q100
) + dy2 * (
dx1 * q001 + dx2 * q101
)
) + ((z - z1) / (z2 - z1)) * (
dy1 * (
dx1 * q010 + dx2 * q110
) + dy2 * (
dx1 * q011 + dx2 * q111
)
);
}
public static double grad(int hash, double x, double y, double z) {
hash &= 15;
double u = hash < 8 ? x : y;
double v = hash < 4 ? y : ((hash == 12 || hash == 14) ? x :
z);
return ((hash & 1) == 0 ? u : -u) + ((hash & 2) == 0 ? v : -v);
}
abstract public double getNoise2D(double x, double z);
abstract public double getNoise3D(double x, double y, double z);
public double noise2D(double x, double z) {
return noise2D(x, z, false);
}
public double noise2D(double x, double z, boolean normalized) {
double result = 0;
double amp = 1;
double freq = 1;
double max = 0;
x *= this.expansion;
z *= this.expansion;
for (int i = 0; i < this.octaves; ++i) {
result += this.getNoise2D(x * freq, z * freq) * amp;
max += amp;
freq *= 2;
amp *= this.persistence;
}
if (normalized) {
result /= max;
}
return result;
}
public double noise3D(double x, double y, double z) {
return noise3D(x, y, z, false);
}
public double noise3D(double x, double y, double z, boolean normalized) {
double result = 0;
double amp = 1;
double freq = 1;
double max = 0;
x *= this.expansion;
y *= this.expansion;
z *= this.expansion;
for (int i = 0; i < this.octaves; ++i) {
result += this.getNoise3D(x * freq, y * freq, z * freq) * amp;
max += amp;
freq *= 2;
amp *= this.persistence;
}
if (normalized) {
result /= max;
}
return result;
}
public void setOffset(double x, double y, double z) {
this.offsetX = x;
this.offsetY = y;
this.offsetZ = z;
}
}
| 3,971 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Perlin.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/noise/Perlin.java | package cn.nukkit.level.generator.noise;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class Perlin extends Noise {
public static final int[][] grad3 = {
{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
{1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1},
{0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}
};
public Perlin(NukkitRandom random, double octaves, double persistence) {
this(random, octaves, persistence, 1);
}
public Perlin(NukkitRandom random, double octaves, double persistence, double expansion) {
this.octaves = octaves;
this.persistence = persistence;
this.expansion = expansion;
this.offsetX = random.nextFloat() * 256;
this.offsetY = random.nextFloat() * 256;
this.offsetZ = random.nextFloat() * 256;
this.perm = new int[512];
for (int i = 0; i < 256; ++i) {
this.perm[i] = random.nextBoundedInt(256);
}
for (int i = 0; i < 256; ++i) {
int pos = random.nextBoundedInt(256 - i) + i;
int old = this.perm[i];
this.perm[i] = this.perm[pos];
this.perm[pos] = old;
this.perm[i + 256] = this.perm[i];
}
}
@Override
public double getNoise2D(double x, double y) {
return this.getNoise3D(x, y, 0);
}
@Override
public double getNoise3D(double x, double y, double z) {
x += this.offsetX;
y += this.offsetY;
z += this.offsetZ;
int floorX = (int) x;
int floorY = (int) y;
int floorZ = (int) z;
int X = floorX & 0xFF;
int Y = floorY & 0xFF;
int Z = floorZ & 0xFF;
x -= floorX;
y -= floorY;
z -= floorZ;
//Fade curves
//fX = fade(x);
//fY = fade(y);
//fZ = fade(z);
double fX = x * x * x * (x * (x * 6 - 15) + 10);
double fY = y * y * y * (y * (y * 6 - 15) + 10);
double fZ = z * z * z * (z * (z * 6 - 15) + 10);
//Cube corners
int A = this.perm[X] + Y;
int B = this.perm[X + 1] + Y;
int AA = this.perm[A] + Z;
int AB = this.perm[A + 1] + Z;
int BA = this.perm[B] + Z;
int BB = this.perm[B + 1] + Z;
double AA1 = grad(this.perm[AA], x, y, z);
double BA1 = grad(this.perm[BA], x - 1, y, z);
double AB1 = grad(this.perm[AB], x, y - 1, z);
double BB1 = grad(this.perm[BB], x - 1, y - 1, z);
double AA2 = grad(this.perm[AA + 1], x, y, z - 1);
double BA2 = grad(this.perm[BA + 1], x - 1, y, z - 1);
double AB2 = grad(this.perm[AB + 1], x, y - 1, z - 1);
double BB2 = grad(this.perm[BB + 1], x - 1, y - 1, z - 1);
double xLerp11 = AA1 + fX * (BA1 - AA1);
double zLerp1 = xLerp11 + fY * (AB1 + fX * (BB1 - AB1) - xLerp11);
double xLerp21 = AA2 + fX * (BA2 - AA2);
return zLerp1 + fZ * (xLerp21 + fY * (AB2 + fX * (BB2 - AB2) - xLerp21) - zLerp1);
}
}
| 3,067 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GenerationTask.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/GenerationTask.java | package cn.nukkit.level.generator.task;
import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.level.SimpleChunkManager;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.level.generator.Generator;
import cn.nukkit.scheduler.AsyncTask;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class GenerationTask extends AsyncTask {
public boolean state;
public final int levelId;
public BaseFullChunk chunk;
public GenerationTask(Level level, BaseFullChunk chunk) {
this.state = true;
this.levelId = level.getId();
this.chunk = chunk;
}
@Override
public void onRun() {
Generator generator = GeneratorPool.get(this.levelId);
if (generator == null) {
this.state = false;
return;
}
SimpleChunkManager manager = (SimpleChunkManager) generator.getChunkManager();
if (manager == null) {
this.state = false;
return;
}
synchronized (manager) {
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
manager.setChunk(chunk.getX(), chunk.getZ(), chunk);
generator.generateChunk(chunk.getX(), chunk.getZ());
chunk = manager.getChunk(chunk.getX(), chunk.getZ());
chunk.setGenerated();
this.chunk = chunk.clone();
manager.setChunk(chunk.getX(), chunk.getZ(), null);
}
}
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
if (level != null) {
if (!this.state) {
level.registerGenerator();
return;
}
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
}
| 1,996 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GeneratorRegisterTask.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/GeneratorRegisterTask.java | package cn.nukkit.level.generator.task;
import cn.nukkit.block.Block;
import cn.nukkit.level.Level;
import cn.nukkit.level.SimpleChunkManager;
import cn.nukkit.level.generator.Generator;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.scheduler.AsyncTask;
import java.util.Map;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class GeneratorRegisterTask extends AsyncTask {
public final Class<? extends Generator> generator;
public final Map<String, Object> settings;
public final long seed;
public final int levelId;
public GeneratorRegisterTask(Level level, Generator generator) {
this.generator = generator.getClass();
this.settings = generator.getSettings();
this.seed = level.getSeed();
this.levelId = level.getId();
}
@Override
public void onRun() {
Block.init();
Biome.init();
SimpleChunkManager manager = new SimpleChunkManager(this.seed);
try {
Generator generator = this.generator.getConstructor(Map.class).newInstance(this.settings);
generator.init(manager, new NukkitRandom(manager.getSeed()));
GeneratorPool.put(this.levelId, generator);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| 1,341 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GeneratorPool.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/GeneratorPool.java | package cn.nukkit.level.generator.task;
import cn.nukkit.level.generator.Generator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class GeneratorPool {
private static final Map<Integer, Generator> generators = new ConcurrentHashMap<>();
public static void put(int levelId, Generator generator) {
generators.put(levelId, generator);
}
public static void remove(int levelId) {
generators.remove(levelId);
}
public static boolean exists(int levelId) {
return generators.containsKey(levelId);
}
public static Generator get(int levelId) {
return generators.getOrDefault(levelId, null);
}
}
| 739 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
LightPopulationTask.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/LightPopulationTask.java | package cn.nukkit.level.generator.task;
import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.scheduler.AsyncTask;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class LightPopulationTask extends AsyncTask {
public final int levelId;
public BaseFullChunk chunk;
public LightPopulationTask(Level level, BaseFullChunk chunk) {
this.levelId = level.getId();
this.chunk = chunk;
}
@Override
public void onRun() {
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
chunk.recalculateHeightMap();
chunk.populateSkyLight();
chunk.setLightPopulated();
this.chunk = chunk.clone();
}
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
BaseFullChunk chunk = this.chunk.clone();
if (level != null) {
if (chunk == null) {
return;
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
}
| 1,154 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GeneratorUnregisterTask.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/GeneratorUnregisterTask.java | package cn.nukkit.level.generator.task;
import cn.nukkit.level.Level;
import cn.nukkit.scheduler.AsyncTask;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class GeneratorUnregisterTask extends AsyncTask {
public final int levelId;
public GeneratorUnregisterTask(Level level) {
this.levelId = level.getId();
}
@Override
public void onRun() {
GeneratorPool.remove(levelId);
}
}
| 430 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulationTask.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/task/PopulationTask.java | package cn.nukkit.level.generator.task;
import cn.nukkit.Server;
import cn.nukkit.level.Level;
import cn.nukkit.level.SimpleChunkManager;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.level.generator.Generator;
import cn.nukkit.scheduler.AsyncTask;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PopulationTask extends AsyncTask {
public boolean state;
public final int levelId;
public BaseFullChunk chunk;
public final BaseFullChunk[] chunks = new BaseFullChunk[9];
public PopulationTask(Level level, BaseFullChunk chunk) {
this.state = true;
this.levelId = level.getId();
this.chunk = chunk;
int i = 0;
for (int z = -1; z <= 1; z++) {
for (int x = -1; x <= 1; x++, i++) {
if (i == 4) continue;
BaseFullChunk ck = level.getChunk(chunk.getX() + x, chunk.getZ() + z, false);
this.chunks[i] = ck;
}
}
}
@Override
public void onRun() {
Generator generator = GeneratorPool.get(this.levelId);
if (generator == null) {
this.state = false;
return;
}
SimpleChunkManager manager = (SimpleChunkManager) generator.getChunkManager();
if (manager == null) {
this.state = false;
return;
}
synchronized (generator.getChunkManager()) {
BaseFullChunk[] chunks = new BaseFullChunk[9];
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
for (int i = 0; i < 9; i++) {
if (i == 4) {
continue;
}
int xx = -1 + i % 3;
int zz = -1 + (i / 3);
BaseFullChunk ck = this.chunks[i];
if (ck == null) {
try {
chunks[i] = (BaseFullChunk) this.chunk.getClass().getMethod("getEmptyChunk", int.class, int.class).invoke(null, chunk.getX() + xx, chunk.getZ() + zz);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
chunks[i] = ck.clone();
}
}
manager.setChunk(chunk.getX(), chunk.getZ(), chunk);
if (!chunk.isGenerated()) {
generator.generateChunk(chunk.getX(), chunk.getZ());
chunk.setGenerated();
}
for (BaseFullChunk c : chunks) {
if (c != null) {
manager.setChunk(c.getX(), c.getZ(), c);
if (!c.isGenerated()) {
generator.generateChunk(c.getX(), c.getZ());
c = manager.getChunk(c.getX(), c.getZ());
c.setGenerated();
manager.setChunk(c.getX(), c.getZ(), c);
}
}
}
generator.populateChunk(chunk.getX(), chunk.getZ());
chunk = manager.getChunk(chunk.getX(), chunk.getZ());
chunk.recalculateHeightMap();
chunk.populateSkyLight();
chunk.setLightPopulated();
chunk.setPopulated();
this.chunk = chunk.clone();
manager.setChunk(chunk.getX(), chunk.getZ(), null);
for (int i = 0; i < chunks.length; i++) {
if (i == 4) {
continue;
}
BaseFullChunk c = chunks[i];
if (c != null) {
c = chunks[i] = manager.getChunk(c.getX(), c.getZ());
if (!c.hasChanged()) {
chunks[i] = null;
}
}
}
manager.cleanChunks();
for (int i = 0; i < 9; i++) {
if (i == 4) {
continue;
}
this.chunks[i] = chunks[i] != null ? chunks[i].clone() : null;
}
}
}
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
if (level != null) {
if (!this.state) {
level.registerGenerator();
return;
}
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
for (int i = 0; i < 9; i++) {
if (i == 4) {
continue;
}
BaseFullChunk c = this.chunks[i];
if (c != null) {
c = c.clone();
level.generateChunkCallback(c.getX(), c.getZ(), c);
}
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
}
| 4,929 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SwampBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/SwampBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockFlower;
import cn.nukkit.level.generator.populator.PopulatorFlower;
import cn.nukkit.level.generator.populator.PopulatorLilyPad;
import cn.nukkit.level.generator.populator.tree.SwampTreePopulator;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class SwampBiome extends GrassyBiome {
public SwampBiome() {
super();
PopulatorLilyPad lilypad = new PopulatorLilyPad();
lilypad.setBaseAmount(4);
SwampTreePopulator trees = new SwampTreePopulator();
trees.setBaseAmount(2);
PopulatorFlower flower = new PopulatorFlower();
flower.setBaseAmount(2);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_BLUE_ORCHID);
this.addPopulator(trees);
this.addPopulator(flower);
this.addPopulator(lilypad);
this.setElevation(62, 63);
this.temperature = 0.8;
this.rainfall = 0.9;
}
@Override
public String getName() {
return "Swamp";
}
@Override
public int getColor() {
return 0x6a7039;
}
}
| 1,148 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SmallMountainsBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/SmallMountainsBiome.java | package cn.nukkit.level.generator.biome;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class SmallMountainsBiome extends MountainsBiome {
public SmallMountainsBiome() {
super();
this.setElevation(63, 97);
}
@Override
public String getName() {
return "Small Mountains";
}
}
| 332 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
NormalBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/NormalBiome.java | package cn.nukkit.level.generator.biome;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class NormalBiome extends Biome {
@Override
public int getColor() {
return this.grassColor;
}
}
| 223 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BiomeSelector.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/BiomeSelector.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.noise.Simplex;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class BiomeSelector {
private final Biome fallback;
private final Simplex temperature;
private final Simplex rainfall;
private final boolean[] biomes = new boolean[256];
private int[] map = new int[64 * 64];
public BiomeSelector(NukkitRandom random, Biome fallback) {
this.fallback = fallback;
this.temperature = new Simplex(random, 2F, 1F / 8F, 1F / 1024F);
this.rainfall = new Simplex(random, 2F, 1F / 8F, 1F / 1024F);
}
public int lookup(double temperature, double rainfall) {
if (rainfall < 0.25) {
return Biome.SWAMP;
} else if (rainfall < 0.60) {
if (temperature < 0.25) {
return Biome.ICE_PLAINS;
} else if (temperature < 0.75) {
return Biome.DESERT;
} else {
return Biome.SAVANNA;
}
} else if (rainfall < 0.80) {
if (temperature < 0.25) {
return Biome.TAIGA;
} else {
return Biome.FOREST;
}
} else {
if (rainfall < 1.0) {
return Biome.JUNGLE;
}
}
return Biome.PLAINS;
}
public void recalculate() {
this.map = new int[64 * 64];
for (int i = 0; i < 64; ++i) {
for (int j = 0; j < 64; ++j) {
this.map[i + (j << 6)] = this.lookup(i / 63d, j / 63d);
}
}
}
public void addBiome(Biome biome) {
this.biomes[biome.getId()] = true;
}
public double getTemperature(double x, double z) {
return (this.temperature.noise2D(x, z, true) + 1) / 2;
}
public double getRainfall(double x, double z) {
return (this.rainfall.noise2D(x, z, true) + 1) / 2;
}
public Biome pickBiome(double x, double z) {
int temperature = (int) (this.getTemperature(x, z) * 63);
int rainfall = (int) (this.getRainfall(x, z) * 63);
int biomeId = this.map[temperature + (rainfall << 6)];
if (this.biomes[biomeId]) {
return Biome.getBiome(biomeId);
} else {
return this.fallback;
}
}
}
| 2,367 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SavannaBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/SavannaBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.generator.populator.PopulatorFlower;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.tree.SavannaTreePopulator;
public class SavannaBiome extends GrassyBiome {
public SavannaBiome() {
super();
SavannaTreePopulator tree = new SavannaTreePopulator(BlockSapling.ACACIA);
tree.setBaseAmount(1);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(20);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(20);
PopulatorFlower flower = new PopulatorFlower();
flower.setBaseAmount(4);
this.addPopulator(tallGrass);
this.addPopulator(grass);
this.addPopulator(tree);
this.addPopulator(flower);
this.setElevation(62, 68);
this.temperature = 1.2f;
this.rainfall = 0.0f;
}
@Override
public String getName() {
return "Savanna";
}
}
| 1,144 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
MountainsBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/MountainsBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.PopulatorTree;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class MountainsBiome extends GrassyBiome {
public MountainsBiome() {
super();
PopulatorTree tree = new PopulatorTree();
tree.setBaseAmount(1);
this.addPopulator(tree);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(30);
this.addPopulator(grass);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(1);
this.addPopulator(tallGrass);
this.setElevation(63, 127);
this.temperature = 0.4;
this.rainfall = 0.5;
}
@Override
public String getName() {
return "Mountains";
}
}
| 970 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
ForestBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/ForestBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.PopulatorTree;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class ForestBiome extends GrassyBiome {
public static final int TYPE_NORMAL = 0;
public static final int TYPE_BIRCH = 1;
public final int type;
public ForestBiome() {
this(TYPE_NORMAL);
}
public ForestBiome(int type) {
super();
this.type = type;
PopulatorTree trees = new PopulatorTree(type == TYPE_BIRCH ? BlockSapling.BIRCH : BlockSapling.OAK);
trees.setBaseAmount(5);
this.addPopulator(trees);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(30);
this.addPopulator(grass);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(3);
this.addPopulator(tallGrass);
this.setElevation(63, 81);
if (type == TYPE_BIRCH) {
this.temperature = 0.5;
this.rainfall = 0.5;
} else {
this.temperature = 0.7;
this.temperature = 0.8;
}
}
@Override
public String getName() {
return this.type == TYPE_BIRCH ? "Birch Forest" : "Forest";
}
}
| 1,419 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
RoofedForestMBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/RoofedForestMBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.populator.MushroomPopulator;
import cn.nukkit.level.generator.populator.PopulatorFlower;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.tree.DarkOakTreePopulator;
public class RoofedForestMBiome extends GrassyBiome {
public RoofedForestMBiome() {
super();
DarkOakTreePopulator tree = new DarkOakTreePopulator();
tree.setBaseAmount(20);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(10);
PopulatorFlower flower = new PopulatorFlower();
flower.setBaseAmount(2);
MushroomPopulator mushroom = new MushroomPopulator();
mushroom.setBaseAmount(1);
mushroom.setRandomAmount(1);
this.addPopulator(grass);
this.addPopulator(tree);
this.addPopulator(flower);
this.addPopulator(mushroom);
this.setElevation(63, 127);
this.temperature = 0.7f;
this.rainfall = 0.8f;
}
@Override
public String getName() {
return "Roofed ForestM";
}
}
| 1,140 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
TaigaBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/TaigaBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.PopulatorTree;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class TaigaBiome extends SnowyBiome {
public TaigaBiome() {
super();
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(6);
this.addPopulator(grass);
PopulatorTree trees = new PopulatorTree(BlockSapling.SPRUCE);
trees.setBaseAmount(10);
this.addPopulator(trees);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(1);
this.addPopulator(tallGrass);
this.setElevation(63, 81);
this.temperature = 0.05;
this.rainfall = 0.8;
}
@Override
public String getName() {
return "Taiga";
}
}
| 979 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
GrassyBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/GrassyBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockDirt;
import cn.nukkit.block.BlockGrass;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class GrassyBiome extends NormalBiome implements CaveBiome {
public GrassyBiome() {
this.setGroundCover(new Block[]{
new BlockGrass(),
new BlockDirt(),
new BlockDirt(),
new BlockDirt(),
new BlockDirt()
});
}
@Override
public int getSurfaceBlock() {
return Block.GRASS;
}
@Override
public int getGroundBlock() {
return Block.DIRT;
}
@Override
public int getStoneBlock() {
return Block.STONE;
}
}
| 769 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
JungleBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/JungleBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.tree.JungleBigTreePopulator;
import cn.nukkit.level.generator.populator.tree.JungleTreePopulator;
public class JungleBiome extends GrassyBiome {
public JungleBiome() {
super();
JungleTreePopulator trees = new JungleTreePopulator();
JungleBigTreePopulator bigTrees = new JungleBigTreePopulator();
trees.setBaseAmount(10);
bigTrees.setBaseAmount(6);
//PopulatorTallGrass tallGrass = new PopulatorTallGrass();
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(20);
//PopulatorFern fern = new PopulatorFern();
//fern.setBaseAmount(30);
this.addPopulator(grass);
//this.addPopulator(fern);
this.addPopulator(bigTrees);
this.addPopulator(trees);
this.setElevation(62, 63);
this.temperature = 1.2f;
this.rainfall = 0.9f;
}
@Override
public String getName() {
return "Jungle";
}
}
| 1,102 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SandyBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/SandyBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSand;
import cn.nukkit.block.BlockSandstone;
import cn.nukkit.level.generator.populator.PopulatorCactus;
import cn.nukkit.level.generator.populator.PopulatorDeadBush;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class SandyBiome extends NormalBiome implements CaveBiome {
public SandyBiome() {
PopulatorCactus cactus = new PopulatorCactus();
cactus.setBaseAmount(2);
PopulatorDeadBush deadbush = new PopulatorDeadBush();
deadbush.setBaseAmount(2);
this.addPopulator(cactus);
this.addPopulator(deadbush);
this.setGroundCover(new Block[]{
new BlockSand(),
new BlockSand(),
new BlockSandstone(),
new BlockSandstone(),
new BlockSandstone()
});
}
@Override
public int getSurfaceBlock() {
return Block.SAND;
}
@Override
public int getGroundBlock() {
return Block.SAND;
}
@Override
public int getStoneBlock() {
return Block.SANDSTONE;
}
}
| 1,172 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SnowyBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/SnowyBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockDirt;
import cn.nukkit.block.BlockGrass;
import cn.nukkit.block.BlockSnowLayer;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class SnowyBiome extends NormalBiome {
public SnowyBiome() {
this.setGroundCover(new Block[]{
new BlockSnowLayer(),
new BlockGrass(),
new BlockDirt(),
new BlockDirt(),
new BlockDirt()
});
}
}
| 542 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
MushroomIsland.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/MushroomIsland.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockDirt;
import cn.nukkit.block.BlockMycelium;
import cn.nukkit.level.generator.populator.MushroomPopulator;
public class MushroomIsland extends NormalBiome implements CaveBiome {
public MushroomIsland() {
this.setGroundCover(new Block[]{new BlockMycelium(), new BlockDirt(), new BlockDirt(), new BlockDirt(), new BlockDirt()});
MushroomPopulator mushroomPopulator = new MushroomPopulator();
mushroomPopulator.setBaseAmount(1);
addPopulator(mushroomPopulator);
setElevation(60, 70);
temperature = 0.9f;
rainfall = 1.0f;
}
@Override
public String getName() {
return "Mushroom Island";
}
@Override
public int getSurfaceBlock() {
return Block.MYCELIUM;
}
@Override
public int getGroundBlock() {
return Block.DIRT;
}
@Override
public int getStoneBlock() {
return Block.STONE;
}
}
| 1,026 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
RiverBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/RiverBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.PopulatorSugarcane;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.PopulatorTallSugarcane;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class RiverBiome extends WateryBiome {
public RiverBiome() {
super();
PopulatorSugarcane sugarcane = new PopulatorSugarcane();
sugarcane.setBaseAmount(6);
PopulatorTallSugarcane tallSugarcane = new PopulatorTallSugarcane();
tallSugarcane.setBaseAmount(60);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(30);
this.addPopulator(grass);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(5);
this.addPopulator(tallGrass);
this.addPopulator(sugarcane);
this.addPopulator(tallSugarcane);
this.setElevation(58, 62);
this.temperature = 0.5;
this.rainfall = 0.7;
}
@Override
public String getName() {
return "River";
}
}
| 1,177 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
HellBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/HellBiome.java | package cn.nukkit.level.generator.biome;
public class HellBiome extends Biome {
@Override
public String getName() {
return "Hell";
}
@Override
public int getColor() {
return -3394765;
}
}
| 230 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
RoofedForestBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/RoofedForestBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.level.generator.populator.MushroomPopulator;
import cn.nukkit.level.generator.populator.PopulatorFlower;
import cn.nukkit.level.generator.populator.PopulatorGrass;
import cn.nukkit.level.generator.populator.tree.DarkOakTreePopulator;
public class RoofedForestBiome extends GrassyBiome {
public RoofedForestBiome() {
super();
DarkOakTreePopulator tree = new DarkOakTreePopulator();
tree.setBaseAmount(30);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(10);
PopulatorFlower flower = new PopulatorFlower();
flower.setBaseAmount(2);
MushroomPopulator mushroom = new MushroomPopulator();
mushroom.setBaseAmount(0);
mushroom.setRandomAmount(1);
this.addPopulator(mushroom);
this.addPopulator(grass);
this.addPopulator(tree);
this.addPopulator(flower);
this.setElevation(62, 68);
this.temperature = 0.7f;
this.rainfall = 0.8f;
}
@Override
public String getName() {
return "Roofed Forest";
}
}
| 1,137 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
OceanBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/OceanBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.level.generator.populator.PopulatorSugarcane;
import cn.nukkit.level.generator.populator.PopulatorTallSugarcane;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class OceanBiome extends WateryBiome {
public OceanBiome() {
super();
PopulatorSugarcane sugarcane = new PopulatorSugarcane();
sugarcane.setBaseAmount(6);
PopulatorTallSugarcane tallSugarcane = new PopulatorTallSugarcane();
tallSugarcane.setBaseAmount(60);
this.addPopulator(sugarcane);
this.addPopulator(tallSugarcane);
this.setElevation(46, 58);
this.temperature = 0.5;
this.rainfall = 0.5;
}
@Override
public Block[] getGroundCover() {
return super.getGroundCover();
}
@Override
public String getName() {
return "Ocean";
}
}
| 921 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BeachBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/BeachBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSand;
import cn.nukkit.block.BlockSandstone;
/**
* Author: PeratX
* Nukkit Project
*/
public class BeachBiome extends SandyBiome {
public BeachBiome() {
//Todo: SugarCane
this.setElevation(62, 65);
this.temperature = 2;
this.rainfall = 0;
this.setGroundCover(new Block[]{
new BlockSand(),
new BlockSand(),
new BlockSandstone(),
new BlockSandstone(),
new BlockSandstone()
});
}
@Override
public String getName() {
return "Beach";
}
}
| 696 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PlainBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/PlainBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockFlower;
import cn.nukkit.level.generator.populator.*;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PlainBiome extends GrassyBiome {
public PlainBiome() {
super();
PopulatorSugarcane sugarcane = new PopulatorSugarcane();
sugarcane.setBaseAmount(6);
PopulatorTallSugarcane tallSugarcane = new PopulatorTallSugarcane();
tallSugarcane.setBaseAmount(60);
PopulatorGrass grass = new PopulatorGrass();
grass.setBaseAmount(40);
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(7);
PopulatorFlower flower = new PopulatorFlower();
flower.setBaseAmount(10);
flower.addType(Block.DANDELION, 0);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_POPPY);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_AZURE_BLUET);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_RED_TULIP);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_ORANGE_TULIP);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_WHITE_TULIP);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_PINK_TULIP);
flower.addType(Block.RED_FLOWER, BlockFlower.TYPE_OXEYE_DAISY);
this.addPopulator(sugarcane);
this.addPopulator(tallSugarcane);
this.addPopulator(grass);
this.addPopulator(tallGrass);
this.addPopulator(flower);
this.setElevation(63, 74);
this.temperature = 0.8;
this.rainfall = 0.4;
}
@Override
public String getName() {
return "Plains";
}
}
| 1,701 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
DesertBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/DesertBiome.java | package cn.nukkit.level.generator.biome;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class DesertBiome extends SandyBiome {
public DesertBiome() {
super();
this.setElevation(63, 74);
this.temperature = 2;
this.rainfall = 0;
}
@Override
public String getName() {
return "Desert";
}
}
| 357 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
CaveBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/CaveBiome.java | package cn.nukkit.level.generator.biome;
/**
* Nukkit Project
* Author: MagicDroidX
*/
public interface CaveBiome {
int getStoneBlock();
int getSurfaceBlock();
int getGroundBlock();
}
| 202 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
MesaBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/MesaBiome.java | package cn.nukkit.level.generator.biome;
public class MesaBiome extends SandyBiome {
public MesaBiome() {
//WIP
}
@Override
public String getName() {
return "Mesa";
}
}
| 208 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Biome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/Biome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.math.NukkitRandom;
import java.util.ArrayList;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class Biome {
public static final int OCEAN = 0;
public static final int PLAINS = 1;
public static final int DESERT = 2;
public static final int MOUNTAINS = 3;
public static final int FOREST = 4;
public static final int TAIGA = 5;
public static final int SWAMP = 6;
public static final int RIVER = 7;
public static final int JUNGLE = 21;
public static final int SAVANNA = 35;
public static final int ROOFED_FOREST = 29;
public static final int ROOFED_FOREST_M = 157;
public static final int MUSHROOM_ISLAND = 14;
public static final int HELL = 8;
public static final int ICE_PLAINS = 12;
public static final int BEACH = 16;
public static final int SMALL_MOUNTAINS = 20;
public static final int BIRCH_FOREST = 27;
public static final int MAX_BIOMES = 256;
private static final Biome[] biomes = new Biome[MAX_BIOMES];
private int id;
private boolean registered = false;
private final ArrayList<Populator> populators = new ArrayList<>();
private int minElevation;
private int maxElevation;
private Block[] groundCover;
protected double rainfall = 0.5;
protected double temperature = 0.5;
protected int grassColor = 0;
protected static void register(int id, Biome biome) {
biome.setId(id);
biome.grassColor = generateBiomeColor(biome.getTemperature(), biome.getRainfall());
biomes[id] = biome;
}
public static void init() {
register(OCEAN, new OceanBiome());
register(PLAINS, new PlainBiome());
register(DESERT, new DesertBiome());
register(MOUNTAINS, new MountainsBiome());
register(FOREST, new ForestBiome());
register(TAIGA, new TaigaBiome());
register(SWAMP, new SwampBiome());
register(RIVER, new RiverBiome());
register(ICE_PLAINS, new IcePlainsBiome());
register(SMALL_MOUNTAINS, new SmallMountainsBiome());
register(BIRCH_FOREST, new ForestBiome(ForestBiome.TYPE_BIRCH));
register(JUNGLE, new JungleBiome());
register(ROOFED_FOREST, new RoofedForestBiome());
register(ROOFED_FOREST_M, new RoofedForestMBiome());
register(MUSHROOM_ISLAND, new MushroomIsland());
register(SAVANNA, new SavannaBiome());
register(BEACH, new BeachBiome());
register(HELL, new HellBiome());
}
public static Biome getBiome(int id) {
Biome biome = biomes[id];
return biome != null ? biome : biomes[OCEAN];
}
/**
* Get Biome by name.
*
* @param name Name of biome. Name could contain symbol "_" instead of space
* @return Biome. Null - when biome was not found
*/
public static Biome getBiome(String name) {
for (Biome biome : biomes) {
if (biome != null) {
if (biome.getName().equalsIgnoreCase(name.replace("_", " "))) return biome;
}
}
return null;
}
public void clearPopulators() {
this.populators.clear();
}
public void addPopulator(Populator populator) {
this.populators.add(populator);
}
public void populateChunk(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
for (Populator populator : populators) {
populator.populate(level, chunkX, chunkZ, random);
}
}
public ArrayList<Populator> getPopulators() {
return populators;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public abstract String getName();
public int getMinElevation() {
return minElevation;
}
public int getMaxElevation() {
return maxElevation;
}
public void setElevation(int min, int max) {
this.minElevation = min;
this.maxElevation = max;
}
public Block[] getGroundCover() {
return groundCover;
}
public void setGroundCover(Block[] covers) {
this.groundCover = covers;
}
public double getTemperature() {
return temperature;
}
public double getRainfall() {
return rainfall;
}
private static int generateBiomeColor(double temperature, double rainfall) {
double x = (1 - temperature) * 255;
double z = (1 - rainfall * temperature) * 255;
double[] c = interpolateColor(256, x, z, new double[]{0x47, 0xd0, 0x33}, new double[]{0x6c, 0xb4, 0x93}, new double[]{0xbf, 0xb6, 0x55}, new double[]{0x80, 0xb4, 0x97});
return ((int) c[0] << 16) | ((int) c[1] << 8) | (int) (c[2]);
}
private static double[] interpolateColor(double size, double x, double z, double[] c1, double[] c2, double[] c3, double[] c4) {
double[] l1 = lerpColor(c1, c2, x / size);
double[] l2 = lerpColor(c3, c4, x / size);
return lerpColor(l1, l2, z / size);
}
private static double[] lerpColor(double[] a, double[] b, double s) {
double invs = 1 - s;
return new double[]{a[0] * invs + b[0] * s, a[1] * invs + b[1] * s, a[2] * invs + b[2] * s};
}
abstract public int getColor();
@Override
public int hashCode() {
return getId();
}
@Override
public boolean equals(Object obj) {
return hashCode() == obj.hashCode();
}
}
| 5,628 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
WateryBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/WateryBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockDirt;
/**
* author: Angelic47
* Nukkit Project
*/
public abstract class WateryBiome extends NormalBiome implements CaveBiome {
public WateryBiome() {
this.setGroundCover(new Block[]{
new BlockDirt(),
new BlockDirt(),
new BlockDirt(),
new BlockDirt(),
new BlockDirt()
});
}
@Override
public int getSurfaceBlock() {
return Block.DIRT;
}
@Override
public int getGroundBlock() {
return Block.DIRT;
}
@Override
public int getStoneBlock() {
return Block.STONE;
}
}
| 765 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
IcePlainsBiome.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/biome/IcePlainsBiome.java | package cn.nukkit.level.generator.biome;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.generator.populator.PopulatorTallGrass;
import cn.nukkit.level.generator.populator.PopulatorTree;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class IcePlainsBiome extends SnowyBiome {
public IcePlainsBiome() {
super();
PopulatorTallGrass tallGrass = new PopulatorTallGrass();
tallGrass.setBaseAmount(5);
PopulatorTree trees = new PopulatorTree(BlockSapling.SPRUCE);
trees.setBaseAmount(1);
trees.setRandomAmount(1);
this.addPopulator(tallGrass);
this.addPopulator(trees);
this.setElevation(63, 74);
this.temperature = 0D;
this.rainfall = 0.5D;
}
public String getName() {
return "Ice Plains";
}
}
| 828 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
MushroomPopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/MushroomPopulator.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.mushroom.BigMushroom;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public class MushroomPopulator extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public MushroomPopulator() {
this(-1);
}
public MushroomPopulator(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new BigMushroom(type).generate(level, random, v.setComponents(x, y, z));
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 1,853 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorFlower.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorFlower.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockFlower;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import java.util.ArrayList;
import java.util.List;
/**
* author: Angelic47
* contributer: Niall Lindsay <Niall7459>
* <p>
* Nukkit Project
*/
public class PopulatorFlower extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final List<int[]> flowerTypes = new ArrayList<>();
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
public void addType(int a, int b) {
int[] c = new int[2];
c[0] = a;
c[1] = b;
this.flowerTypes.add(c);
}
public List<int[]> getTypes() {
return this.flowerTypes;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
if (flowerTypes.size() == 0) {
this.addType(Block.RED_FLOWER, BlockFlower.TYPE_POPPY);
this.addType(Block.DANDELION, 0);
}
int endNum = this.flowerTypes.size();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canFlowerStay(x, y, z)) {
int[] type = this.flowerTypes.get(random.nextRange(0, endNum - 1));
this.level.setBlockIdAt(x, y, z, type[0]);
this.level.setBlockDataAt(x, y, z, type[1]);
}
}
}
private boolean canFlowerStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS;
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 2,562 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorTallGrass.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorTallGrass.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PopulatorTallGrass extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canTallGrassStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.DOUBLE_PLANT);
this.level.setBlockDataAt(x, y, z, 2);
this.level.setBlockIdAt(x, y + 1, z, Block.DOUBLE_PLANT);
this.level.setBlockDataAt(x, y + 1, z, 10);
}
}
}
private boolean canTallGrassStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS && this.level.getBlockIdAt(x, y + 1, z) == Block.AIR;
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 2,043 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorRavines.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorRavines.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.math.MathHelper;
import cn.nukkit.math.NukkitRandom;
import java.util.Random;
public class PopulatorRavines extends Populator {
protected int checkAreaSize = 8;
private Random random;
private long worldLong1;
private long worldLong2;
private int ravineRarity = 1;//2
private int ravineMinAltitude = 20;
private int ravineMaxAltitude = 67;
private int ravineMinLength = 84;
private int ravineMaxLength = 111;
private double ravineDepth = 3;
private int worldHeightCap = 1 << 8;
private float[] a = new float[1024];
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.random = new Random();
this.random.setSeed(level.getSeed());
worldLong1 = this.random.nextLong();
worldLong2 = this.random.nextLong();
int i = this.checkAreaSize;
for (int x = chunkX - i; x <= chunkX + i; x++)
for (int z = chunkZ - i; z <= chunkZ + i; z++) {
long l3 = x * worldLong1;
long l4 = z * worldLong2;
this.random.setSeed(l3 ^ l4 ^ level.getSeed());
generateChunk(chunkX, chunkZ, level.getChunk(chunkX, chunkZ));
}
}
protected void generateChunk(int chunkX, int chunkZ, FullChunk generatingChunkBuffer) {
if (this.random.nextInt(300) >= this.ravineRarity)
return;
double d1 = (chunkX * 16) + this.random.nextInt(16);
double d2 = numberInRange(random, this.ravineMinAltitude, this.ravineMaxAltitude);
double d3 = (chunkZ * 16) + this.random.nextInt(16);
int i = 1;
for (int j = 0; j < i; j++) {
float f1 = this.random.nextFloat() * 3.141593F * 2.0F;
float f2 = (this.random.nextFloat() - 0.5F) * 2.0F / 8.0F;
float f3 = (this.random.nextFloat() * 2.0F + this.random.nextFloat()) * 2.0F;
int size = numberInRange(random, this.ravineMinLength, this.ravineMaxLength);
createRavine(this.random.nextLong(), generatingChunkBuffer, d1, d2, d3, f3, f1, f2, size, this.ravineDepth);
}
}
protected void createRavine(long paramLong, FullChunk generatingChunkBuffer, double paramDouble1, double paramDouble2, double paramDouble3,
float paramFloat1, float paramFloat2, float paramFloat3, int size, double paramDouble4) {
Random localRandom = new Random(paramLong);
int chunkX = generatingChunkBuffer.getX();
int chunkZ = generatingChunkBuffer.getZ();
double d1 = chunkX * 16 + 8;
double d2 = chunkZ * 16 + 8;
float f1 = 0.0F;
float f2 = 0.0F;
int i = 0;
float f3 = 1.0F;
for (int j = 0; ; j++) {
if (j >= worldHeightCap)
break;
if ((j == 0) || (localRandom.nextInt(3) == 0)) {
f3 = 1.0F + localRandom.nextFloat() * localRandom.nextFloat() * 1.0F;
}
this.a[j] = (f3 * f3);
}
for (int stepCount = 0; stepCount < size; stepCount++) {
double d3 = 1.5D + MathHelper.sin(stepCount * 3.141593F / size) * paramFloat1 * 1.0F;
double d4 = d3 * paramDouble4;
d3 *= (localRandom.nextFloat() * 0.25D + 0.75D);
d4 *= (localRandom.nextFloat() * 0.25D + 0.75D);
float f4 = MathHelper.cos(paramFloat3);
float f5 = MathHelper.sin(paramFloat3);
paramDouble1 += MathHelper.cos(paramFloat2) * f4;
paramDouble2 += f5;
paramDouble3 += MathHelper.sin(paramFloat2) * f4;
paramFloat3 *= 0.7F;
paramFloat3 += f2 * 0.05F;
paramFloat2 += f1 * 0.05F;
f2 *= 0.8F;
f1 *= 0.5F;
f2 += (localRandom.nextFloat() - localRandom.nextFloat()) * localRandom.nextFloat() * 2.0F;
f1 += (localRandom.nextFloat() - localRandom.nextFloat()) * localRandom.nextFloat() * 4.0F;
if ((i == 0) && (localRandom.nextInt(4) == 0)) {
continue;
}
double d5 = paramDouble1 - d1;
double d6 = paramDouble3 - d2;
double d7 = size - stepCount;
double d8 = paramFloat1 + 2.0F + 16.0F;
if (d5 * d5 + d6 * d6 - d7 * d7 > d8 * d8) {
return;
}
if ((paramDouble1 < d1 - 16.0D - d3 * 2.0D) || (paramDouble3 < d2 - 16.0D - d3 * 2.0D) || (paramDouble1 > d1 + 16.0D + d3 * 2.0D) || (paramDouble3 > d2 + 16.0D + d3 * 2.0D))
continue;
int k = MathHelper.floor(paramDouble1 - d3) - (chunkX * 16) - 1;
int m = MathHelper.floor(paramDouble1 + d3) - (chunkZ * 16) + 1;
int maxY = MathHelper.floor(paramDouble2 - d4) - 1;
int minY = MathHelper.floor(paramDouble2 + d4) + 1;
int i2 = MathHelper.floor(paramDouble3 - d3) - (chunkX * 16) - 1;
int i3 = MathHelper.floor(paramDouble3 + d3) - (chunkZ * 16) + 1;
if (k < 0)
k = 0;
if (m > 16)
m = 16;
if (maxY < 1)
maxY = 1;
if (minY > this.worldHeightCap - 8)
minY = this.worldHeightCap - 8;
if (i2 < 0)
i2 = 0;
if (i3 > 16)
i3 = 16;
int i4 = 0;
for (int localX = k; (i4 == 0) && (localX < m); localX++) {
for (int localZ = i2; (i4 == 0) && (localZ < i3); localZ++) {
for (int localY = minY + 1; (i4 == 0) && (localY >= maxY - 1); localY--) {
if (localY < 0)
continue;
if (localY < this.worldHeightCap) {
int materialAtPosition = generatingChunkBuffer.getBlockId(localX, localY, localZ);
if (materialAtPosition == Block.WATER
|| materialAtPosition == Block.STILL_WATER) {
i4 = 1;
}
if ((localY != maxY - 1) && (localX != k) && (localX != m - 1) && (localZ != i2) && (localZ != i3 - 1))
localY = maxY;
}
}
}
}
if (i4 != 0) {
continue;
}
for (int localX = k; localX < m; localX++) {
double d9 = (localX + (chunkX * 16) + 0.5D - paramDouble1) / d3;
for (int localZ = i2; localZ < i3; localZ++) {
double d10 = (localZ + (chunkZ * 16) + 0.5D - paramDouble3) / d3;
if (d9 * d9 + d10 * d10 < 1.0D) {
for (int localY = minY; localY >= maxY; localY--) {
double d11 = ((localY - 1) + 0.5D - paramDouble2) / d4;
if ((d9 * d9 + d10 * d10) * this.a[localY - 1] + d11 * d11 / 6.0D < 1.0D) {
int material = generatingChunkBuffer.getBlockId(localX, localY, localZ);
if (material == Block.GRASS) {
if (localY - 1 < 10) {
generatingChunkBuffer.setBlock(localX, localY, localZ, Block.LAVA);
} else {
generatingChunkBuffer.setBlock(localX, localY, localZ, Block.AIR);
}
}
}
}
}
}
}
if (i != 0)
break;
}
}
public static int numberInRange(Random random, int min, int max) {
return min + random.nextInt(max - min + 1);
}
} | 8,080 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorTallSugarcane.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorTallSugarcane.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* Nukkit Minecraft PE Server Software
* This class was written by Niall Lindsay <Niall7459>
**/
public class PopulatorTallSugarcane extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canSugarcaneStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.SUGARCANE_BLOCK);
this.level.setBlockDataAt(x, y, z, 1);
}
}
}
private boolean canSugarcaneStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR) && this.level.getBlockDataAt(x, y - 1, z) == Block.SUGARCANE_BLOCK;
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 1,880 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorDeadBush.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorDeadBush.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
public class PopulatorDeadBush extends Populator {
/**
* Author: Niall Lindsay <Niall7459>
*/
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canDeadBushStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.DEAD_BUSH);
this.level.setBlockDataAt(x, y, z, 1);
}
}
}
private boolean canDeadBushStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR && this.level.getBlockIdAt(x, y - 1, z) == Block.SAND);
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 1,834 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorTree.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorTree.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.tree.ObjectTree;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PopulatorTree extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public PopulatorTree() {
this(BlockSapling.OAK);
}
public PopulatorTree(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
ObjectTree.growTree(this.level, x, y, z, random, this.type);
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 1,856 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Populator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/Populator.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public abstract class Populator {
public abstract void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random);
}
| 305 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorGroundCover.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorGroundCover.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PopulatorGroundCover extends Populator {
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
FullChunk chunk = level.getChunk(chunkX, chunkZ);
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
Biome biome = Biome.getBiome(chunk.getBiomeId(x, z));
Block[] cover = biome.getGroundCover();
if (cover != null && cover.length > 0) {
int diffY = 0;
if (!cover[0].isSolid()) {
diffY = 1;
}
int height = chunk.getHeightMap(x, z);
if (height == 0 || height == 255) height = 126;
int y;
for (y = height + 1; y > 0; --y) {
int fullId = chunk.getFullBlock(x, y, z);
if (fullId != 0 && !Block.get(fullId >> 4).isTransparent()) {
break;
}
}
int startY = Math.min(127, y + diffY);
int endY = startY - cover.length;
for (y = startY; y > endY && y >= 0; --y) {
Block b = cover[startY - y];
int blockId = chunk.getBlockId(x, y, z);
if (blockId == 0 && b.isSolid()) {
break;
}
if (b.getDamage() == 0) {
chunk.setBlockId(x, y, z, b.getId());
} else {
chunk.setBlock(x, y, z, b.getId(), b.getDamage());
}
}
}
}
}
}
}
| 2,096 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorGrass.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorGrass.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* author: Angelic47
* Nukkit Project
*/
public class PopulatorGrass extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canGrassStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.TALL_GRASS);
this.level.setBlockDataAt(x, y, z, 0);
}
}
}
private boolean canGrassStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.GRASS;
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 1,840 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorGlowStone.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorGlowStone.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockGlowstone;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.level.generator.object.ore.ObjectOre;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.math.NukkitRandom;
public class PopulatorGlowStone extends Populator {
private ChunkManager level;
private OreType type = new OreType(new BlockGlowstone(), 1, 20, 128, 10);
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
ObjectOre ore = new ObjectOre(random, type, Block.AIR);
for (int i = 0; i < ore.type.clusterCount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1) {
ore.placeObject(level, bx + x, y, bz + z);
}
}
}
private int getHighestWorkableBlock(FullChunk chunk, int x, int z) {
int y;
for (y = 127; y >= 0; y--) {
int b = chunk.getBlockId(x, y, z);
if (b == Block.AIR) {
break;
}
}
return y == 0 ? -1 : y;
}
}
| 1,548 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorOre.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorOre.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.ore.ObjectOre;
import cn.nukkit.level.generator.object.ore.OreType;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* author: MagicDroidX
* Nukkit Project
*/
public class PopulatorOre extends Populator {
private final int replaceId;
private OreType[] oreTypes = new OreType[0];
public PopulatorOre() {
this(Block.STONE);
}
public PopulatorOre(int id) {
this.replaceId = id;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
for (OreType type : this.oreTypes) {
ObjectOre ore = new ObjectOre(random, type, replaceId);
for (int i = 0; i < ore.type.clusterCount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int y = NukkitMath.randomRange(random, ore.type.minHeight, ore.type.maxHeight);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
if (ore.canPlaceObject(level, x, y, z)) {
ore.placeObject(level, x, y, z);
}
}
}
}
public void setOreTypes(OreType[] oreTypes) {
this.oreTypes = oreTypes;
}
}
| 1,409 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorLava.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorLava.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.math.NukkitRandom;
public class PopulatorLava extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private NukkitRandom random;
public void setRandomAmount(int amount) {
this.randomAmount = amount;
}
public void setBaseAmount(int amount) {
this.baseAmount = amount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.random = random;
if (random.nextRange(0, 100) < 5) {
this.level = level;
int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
for (int i = 0; i < amount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
chunk.setBlock(x, y, z, Block.LAVA);
chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
this.lavaSpread(bx + x, y, bz + z);
}
}
}
}
private int getFlowDecay(int x1, int y1, int z1, int x2, int y2, int z2) {
if (this.level.getBlockIdAt(x1, y1, z1) != this.level.getBlockIdAt(x2, y2, z2)) {
return -1;
} else {
return this.level.getBlockDataAt(x2, y2, z2);
}
}
private void lavaSpread(int x, int y, int z) {
if (this.level.getChunk(x >> 4, z >> 4) == null) {
return;
}
int decay = this.getFlowDecay(x, y, z, x, y, z);
int multiplier = 2;
if (decay > 0) {
int smallestFlowDecay = -100;
smallestFlowDecay = this.getSmallestFlowDecay(x, y, z, x, y, z - 1, smallestFlowDecay);
smallestFlowDecay = this.getSmallestFlowDecay(x, y, z, x, y, z + 1, smallestFlowDecay);
smallestFlowDecay = this.getSmallestFlowDecay(x, y, z, x - 1, y, z, smallestFlowDecay);
smallestFlowDecay = this.getSmallestFlowDecay(x, y, z, x + 1, y, z, smallestFlowDecay);
int k = smallestFlowDecay + multiplier;
if (k >= 8 || smallestFlowDecay < 0) {
k = -1;
}
int topFlowDecay = this.getFlowDecay(x, y, z, x, y + 1, z);
if (topFlowDecay >= 0) {
if (topFlowDecay >= 8) {
k = topFlowDecay;
} else {
k = topFlowDecay | 0x08;
}
}
if (decay < 8 && k < 8 && k > 1 && random.nextRange(0, 4) != 0) {
k = decay;
}
if (k != decay) {
decay = k;
if (decay < 0) {
this.level.setBlockIdAt(x, y, z, 0);
} else {
this.level.setBlockIdAt(x, y, z, Block.LAVA);
this.level.setBlockDataAt(x, y, z, decay);
this.lavaSpread(x, y, z);
return;
}
}
}
if (this.canFlowInto(x, y - 1, z)) {
if (decay >= 8) {
this.flowIntoBlock(x, y - 1, z, decay);
} else {
this.flowIntoBlock(x, y - 1, z, decay | 0x08);
}
} else if (decay >= 0 && (decay == 0 || !this.canFlowInto(x, y - 1, z))) {
boolean[] flags = this.getOptimalFlowDirections(x, y, z);
int l = decay + multiplier;
if (decay >= 8) {
l = 1;
}
if (l >= 8) {
return;
}
if (flags[0]) {
this.flowIntoBlock(x - 1, y, z, l);
}
if (flags[1]) {
this.flowIntoBlock(x + 1, y, z, l);
}
if (flags[2]) {
this.flowIntoBlock(x, y, z - 1, l);
}
if (flags[3]) {
this.flowIntoBlock(x, y, z + 1, l);
}
}
}
private void flowIntoBlock(int x, int y, int z, int newFlowDecay) {
if (this.level.getBlockIdAt(x, y, z) == Block.AIR) {
this.level.setBlockIdAt(x, y, z, Block.LAVA);
this.level.setBlockDataAt(x, y, z, newFlowDecay);
this.lavaSpread(x, y, z);
}
}
private boolean canFlowInto(int x, int y, int z) {
int id = this.level.getBlockIdAt(x, y, z);
return id == Block.AIR || id == Block.LAVA || id == Block.STILL_LAVA;
}
private int calculateFlowCost(int xx, int yy, int zz, int accumulatedCost, int previousDirection) {
int cost = 1000;
for (int j = 0; j < 4; ++j) {
if (
(j == 0 && previousDirection == 1) ||
(j == 1 && previousDirection == 0) ||
(j == 2 && previousDirection == 3) ||
(j == 3 && previousDirection == 2)
) {
int x = xx;
int y = yy;
int z = zz;
if (j == 0) {
--x;
} else if (j == 1) {
++x;
} else if (j == 2) {
--z;
} else if (j == 3) {
++z;
}
if (!this.canFlowInto(x, y, z)) {
continue;
} else if (this.canFlowInto(x, y, z) && this.level.getBlockDataAt(x, y, z) == 0) {
continue;
} else if (this.canFlowInto(x, y - 1, z)) {
return accumulatedCost;
}
if (accumulatedCost >= 4) {
continue;
}
int realCost = this.calculateFlowCost(x, y, z, accumulatedCost + 1, j);
if (realCost < cost) {
cost = realCost;
}
}
}
return cost;
}
private boolean[] getOptimalFlowDirections(int xx, int yy, int zz) {
int[] flowCost = {0, 0, 0, 0};
boolean[] isOptimalFlowDirection = {false, false, false, false};
for (int j = 0; j < 4; ++j) {
flowCost[j] = 1000;
int x = xx;
int y = yy;
int z = zz;
if (j == 0) {
--x;
} else if (j == 1) {
++x;
} else if (j == 2) {
--z;
} else if (j == 3) {
++z;
}
if (!this.canFlowInto(x, y, z)) {
continue;
} else if (this.canFlowInto(x, y, z) && this.level.getBlockDataAt(x, y, z) == 0) {
continue;
} else if (this.canFlowInto(x, y - 1, z)) {
flowCost[j] = 0;
} else {
flowCost[j] = this.calculateFlowCost(x, y, z, 1, j);
}
}
int minCost = flowCost[0];
for (int i = 1; i < 4; ++i) {
if (flowCost[i] < minCost) {
minCost = flowCost[i];
}
}
for (int i = 0; i < 4; ++i) {
isOptimalFlowDirection[i] = (flowCost[i] == minCost);
}
return isOptimalFlowDirection;
}
private int getSmallestFlowDecay(int x1, int y1, int z1, int x2, int y2, int z2, int decay) {
int blockDecay = this.getFlowDecay(x1, y1, z1, x2, y2, z2);
if (blockDecay < 0) {
return decay;
} else if (blockDecay >= 8) {
blockDecay = 0;
}
return (decay >= 0 && blockDecay >= decay) ? decay : blockDecay;
}
private int getHighestWorkableBlock(FullChunk chunk, int x, int z) {
int y;
for (y = 127; y >= 0; y--) {
int b = chunk.getBlockId(x, y, z);
if (b == Block.AIR) {
break;
}
}
return y == 0 ? -1 : y;
}
}
| 8,408 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorMineshaft.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorMineshaft.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitRandom;
public class PopulatorMineshaft extends Populator {
/**
* Author: Niall Lindsay <Niall7459>
* Unfinished <WIP>
*/
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
// TODO Auto-generated method stub
}
}
| 414 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorCaves.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorCaves.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.biome.Biome;
import cn.nukkit.level.generator.biome.CaveBiome;
import cn.nukkit.math.MathHelper;
import cn.nukkit.math.NukkitRandom;
import java.util.Random;
/**
* author: Angelic47
* Nukkit Project
*/
public class PopulatorCaves extends Populator {
protected int checkAreaSize = 8;
private Random random;
public static int caveRarity = 7;//7
public static int caveFrequency = 40;//40
public static int caveMinAltitude = 8;
public static int caveMaxAltitude = 128;
public static int individualCaveRarity = 25;//25
public static int caveSystemFrequency = 1;
public static int caveSystemPocketChance = 0;
public static int caveSystemPocketMinSize = 0;
public static int caveSystemPocketMaxSize = 4;
public static boolean evenCaveDistribution = false;
public int worldHeightCap = 128;
public ChunkManager chunk;
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.random = new Random();
this.random.setSeed(level.getSeed());
long worldLong1 = this.random.nextLong();
long worldLong2 = this.random.nextLong();
int size = this.checkAreaSize;
for (int x = chunkX - size; x <= chunkX + size; x++)
for (int z = chunkZ - size; z <= chunkZ + size; z++) {
long randomX = x * worldLong1;
long randomZ = z * worldLong2;
this.random.setSeed(randomX ^ randomZ ^ level.getSeed());
generateChunk(x, z, level.getChunk(chunkX, chunkZ));
}
}
protected void generateLargeCaveNode(long seed, FullChunk chunk, double x, double y, double z) {
generateCaveNode(seed, chunk, x, y, z, 1.0F + this.random.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
}
protected void generateCaveNode(long seed, FullChunk chunk, double x, double y, double z, float radius, float angelOffset, float angel, int angle, int maxAngle, double scale) {
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
double realX = chunkX * 16 + 8;
double realZ = chunkZ * 16 + 8;
float f1 = 0.0F;
float f2 = 0.0F;
Random localRandom = new Random(seed);
if (maxAngle <= 0) {
int checkAreaSize = this.checkAreaSize * 16 - 16;
maxAngle = checkAreaSize - localRandom.nextInt(checkAreaSize / 4);
}
boolean isLargeCave = false;
if (angle == -1) {
angle = maxAngle / 2;
isLargeCave = true;
}
int randomAngel = localRandom.nextInt(maxAngle / 2) + maxAngle / 4;
boolean bigAngel = localRandom.nextInt(6) == 0;
for (; angle < maxAngle; angle++) {
double offsetXZ = 1.5D + MathHelper.sin(angle * 3.141593F / maxAngle) * radius * 1.0F;
double offsetY = offsetXZ * scale;
float cos = MathHelper.cos(angel);
float sin = MathHelper.sin(angel);
x += MathHelper.cos(angelOffset) * cos;
y += sin;
z += MathHelper.sin(angelOffset) * cos;
if (bigAngel)
angel *= 0.92F;
else {
angel *= 0.7F;
}
angel += f2 * 0.1F;
angelOffset += f1 * 0.1F;
f2 *= 0.9F;
f1 *= 0.75F;
f2 += (localRandom.nextFloat() - localRandom.nextFloat()) * localRandom.nextFloat() * 2.0F;
f1 += (localRandom.nextFloat() - localRandom.nextFloat()) * localRandom.nextFloat() * 4.0F;
if ((!isLargeCave) && (angle == randomAngel) && (radius > 1.0F) && (maxAngle > 0)) {
generateCaveNode(localRandom.nextLong(), chunk, x, y, z, localRandom.nextFloat() * 0.5F + 0.5F, angelOffset - 1.570796F, angel / 3.0F, angle, maxAngle, 1.0D);
generateCaveNode(localRandom.nextLong(), chunk, x, y, z, localRandom.nextFloat() * 0.5F + 0.5F, angelOffset + 1.570796F, angel / 3.0F, angle, maxAngle, 1.0D);
return;
}
if ((!isLargeCave) && (localRandom.nextInt(4) == 0)) {
continue;
}
// Check if distance to working point (x and z) too larger than working radius (maybe ??)
double distanceX = x - realX;
double distanceZ = z - realZ;
double angelDiff = maxAngle - angle;
double newRadius = radius + 2.0F + 16.0F;
if (distanceX * distanceX + distanceZ * distanceZ - angelDiff * angelDiff > newRadius * newRadius) {
return;
}
//Boundaries check.
if ((x < realX - 16.0D - offsetXZ * 2.0D) || (z < realZ - 16.0D - offsetXZ * 2.0D) || (x > realX + 16.0D + offsetXZ * 2.0D) || (z > realZ + 16.0D + offsetXZ * 2.0D))
continue;
int xFrom = MathHelper.floor(x - offsetXZ) - chunkX * 16 - 1;
int xTo = MathHelper.floor(x + offsetXZ) - chunkX * 16 + 1;
int yFrom = MathHelper.floor(y - offsetY) - 1;
int yTo = MathHelper.floor(y + offsetY) + 1;
int zFrom = MathHelper.floor(z - offsetXZ) - chunkZ * 16 - 1;
int zTo = MathHelper.floor(z + offsetXZ) - chunkZ * 16 + 1;
if (xFrom < 0)
xFrom = 0;
if (xTo > 16)
xTo = 16;
if (yFrom < 1)
yFrom = 1;
if (yTo > this.worldHeightCap - 8) {
yTo = this.worldHeightCap - 8;
}
if (zFrom < 0)
zFrom = 0;
if (zTo > 16)
zTo = 16;
// Search for water
boolean waterFound = false;
for (int xx = xFrom; (!waterFound) && (xx < xTo); xx++) {
for (int zz = zFrom; (!waterFound) && (zz < zTo); zz++) {
for (int yy = yTo + 1; (!waterFound) && (yy >= yFrom - 1); yy--) {
if (yy >= 0 && yy < this.worldHeightCap) {
int block = chunk.getBlockId(xx, yy, zz);
if (block == Block.WATER || block == Block.STILL_WATER) {
waterFound = true;
}
if ((yy != yFrom - 1) && (xx != xFrom) && (xx != xTo - 1) && (zz != zFrom) && (zz != zTo - 1))
yy = yFrom;
}
}
}
}
if (waterFound) {
continue;
}
// Generate cave
for (int xx = xFrom; xx < xTo; xx++) {
double modX = (xx + chunkX * 16 + 0.5D - x) / offsetXZ;
for (int zz = zFrom; zz < zTo; zz++) {
double modZ = (zz + chunkZ * 16 + 0.5D - z) / offsetXZ;
boolean grassFound = false;
if (modX * modX + modZ * modZ < 1.0D) {
for (int yy = yTo; yy > yFrom; yy--) {
double modY = ((yy - 1) + 0.5D - y) / offsetY;
if ((modY > -0.7D) && (modX * modX + modY * modY + modZ * modZ < 1.0D)) {
Biome biome = Biome.getBiome(chunk.getBiomeId(xx, zz));
if (!(biome instanceof CaveBiome)) {
continue;
}
int material = chunk.getBlockId(xx, yy, zz);
int materialAbove = chunk.getBlockId(xx, yy + 1, zz);
if (material == Block.GRASS || material == Block.MYCELIUM) {
grassFound = true;
}
//TODO: check this
// if (this.isSuitableBlock(material, materialAbove, biome))
{
if (yy - 1 < 10) {
chunk.setBlock(xx, yy, zz, Block.LAVA);
} else {
chunk.setBlock(xx, yy, zz, Block.AIR);
// If grass was just deleted, try to
// move it down
if (grassFound && (chunk.getBlockId(xx, yy - 1, zz) == Block.DIRT)) {
chunk.setBlock(xx, yy - 1, zz, ((CaveBiome) biome).getSurfaceBlock());
}
}
}
}
}
}
}
}
if (isLargeCave) {
break;
}
}
}
protected boolean isSuitableBlock(int block, int blockAbove, Biome biome) {
if (!(biome instanceof CaveBiome)) {
return false;
}
CaveBiome caveBiome = (CaveBiome) biome;
if (block == caveBiome.getStoneBlock()) {
return true;
}
if (block == Block.SAND || block == Block.GRAVEL) {
return !(blockAbove == Block.WATER || blockAbove == Block.STILL_WATER || blockAbove == Block.LAVA || blockAbove == Block.STILL_LAVA);
}
if (block == caveBiome.getGroundBlock()) {
return true;
}
if (block == caveBiome.getSurfaceBlock()) {
return true;
}
// Few hardcoded cases
if (block == Block.TERRACOTTA) {
return true;
}
if (block == Block.SANDSTONE) {
return true;
}
// TODO: add red sandstone case in Minecraft 1.8
return block == Block.SNOW;
}
protected void generateChunk(int chunkX, int chunkZ, FullChunk generatingChunkBuffer) {
int i = this.random.nextInt(this.random.nextInt(this.random.nextInt(caveFrequency) + 1) + 1);
if (evenCaveDistribution)
i = caveFrequency;
if (this.random.nextInt(100) >= caveRarity)
i = 0;
for (int j = 0; j < i; j++) {
double x = chunkX * 16 + this.random.nextInt(16);
double y;
if (evenCaveDistribution)
y = numberInRange(random, caveMinAltitude, caveMaxAltitude);
else
y = this.random.nextInt(this.random.nextInt(caveMaxAltitude - caveMinAltitude + 1) + 1) + caveMinAltitude;
double z = chunkZ * 16 + this.random.nextInt(16);
int count = caveSystemFrequency;
boolean largeCaveSpawned = false;
if (this.random.nextInt(100) <= individualCaveRarity) {
generateLargeCaveNode(this.random.nextLong(), generatingChunkBuffer, x, y, z);
largeCaveSpawned = true;
}
if ((largeCaveSpawned) || (this.random.nextInt(100) <= caveSystemPocketChance - 1)) {
count += numberInRange(random, caveSystemPocketMinSize, caveSystemPocketMaxSize);
}
while (count > 0) {
count--;
float f1 = this.random.nextFloat() * 3.141593F * 2.0F;
float f2 = (this.random.nextFloat() - 0.5F) * 2.0F / 8.0F;
float f3 = this.random.nextFloat() * 2.0F + this.random.nextFloat();
generateCaveNode(this.random.nextLong(), generatingChunkBuffer, x, y, z, f3, f1, f2, 0, 0, 1.0D);
}
}
}
public static int numberInRange(Random random, int min, int max) {
return min + random.nextInt(max - min + 1);
}
}
| 11,866 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorLilyPad.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorLilyPad.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
public class PopulatorLilyPad extends Populator {
/**
* Author: Niall Lindsay <Niall7459>
*/
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canLilyPadStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.WATER_LILY);
this.level.setBlockDataAt(x, y, z, 1);
}
}
}
private boolean canLilyPadStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR || b == Block.SNOW_LAYER) && this.level.getBlockIdAt(x, y - 1, z) == Block.STILL_WATER;
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 1,864 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorSugarcane.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorSugarcane.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
/**
* Nukkit Minecraft PE Server Software
* This class was written by Niall Lindsay <Niall7459>
**/
public class PopulatorSugarcane extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canSugarcaneStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.SUGARCANE_BLOCK);
this.level.setBlockDataAt(x, y, z, 1);
}
}
}
private boolean findWater(int x, int y, int z) {
int count = 0;
for (int i = x - 4; i < (x + 4); i++) {
for (int j = z - 4; j < (z + 4); j++) {
int b = this.level.getBlockIdAt(i, y, j);
if (b == Block.WATER || b == Block.STILL_WATER) {
count++;
}
if (count > 10) {
return true;
}
}
}
return (count > 10);
}
private boolean canSugarcaneStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
int c = this.level.getBlockIdAt(x, y - 1, z);
return (b == Block.AIR) && (c == Block.SAND || c == Block.GRASS) && this.findWater(x, y - 1, z);
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 2,427 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorCactus.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorCactus.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
public class PopulatorCactus extends Populator {
/**
* Author: Niall Lindsay <Niall7459>
*/
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y != -1 && this.canCactusStay(x, y, z)) {
this.level.setBlockIdAt(x, y, z, Block.CACTUS);
this.level.setBlockDataAt(x, y, z, 1);
}
}
}
private boolean canCactusStay(int x, int y, int z) {
int b = this.level.getBlockIdAt(x, y, z);
return (b == Block.AIR && this.level.getBlockIdAt(x, y - 1, z) == Block.SAND && this.level.getBlockIdAt(x + 1, y, z) == Block.AIR && this.level.getBlockIdAt(x - 1, y, z) == Block.AIR && this.level.getBlockIdAt(x, y, z + 1) == Block.AIR && this.level.getBlockIdAt(x, y, z - 1) == Block.AIR);
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y >= 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b != Block.AIR && b != Block.LEAVES && b != Block.LEAVES2 && b != Block.SNOW_LAYER) {
break;
}
}
return y == 0 ? -1 : ++y;
}
}
| 2,037 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
PopulatorGroundFire.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/PopulatorGroundFire.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.format.generic.BaseFullChunk;
import cn.nukkit.math.NukkitRandom;
public class PopulatorGroundFire extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
public void setRandomAmount(int amount) {
this.randomAmount = amount;
}
public void setBaseAmount(int amount) {
this.baseAmount = amount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1 && this.canGroundFireStay(chunk, x, y, z)) {
chunk.setBlock(x, y, z, Block.FIRE);
chunk.setBlockLight(x, y, z, Block.light[Block.FIRE]);
}
}
}
private boolean canGroundFireStay(FullChunk chunk, int x, int y, int z) {
int b = chunk.getBlockId(x, y, z);
return (b == Block.AIR) && chunk.getBlockId(x, y - 1, z) == Block.NETHERRACK;
}
private int getHighestWorkableBlock(FullChunk chunk, int x, int z) {
int y;
for (y = 0; y <= 127; ++y) {
int b = chunk.getBlockId(x, y, z);
if (b == Block.AIR) {
break;
}
}
return y == 0 ? -1 : y;
}
}
| 1,881 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
BasicPopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/BasicPopulator.java | package cn.nukkit.level.generator.populator;
import cn.nukkit.block.Block;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.math.BlockVector3;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public abstract class BasicPopulator {
public abstract boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position);
public void setDecorationDefaults() {
}
protected void setBlockAndNotifyAdequately(ChunkManager level, BlockVector3 pos, Block state) {
setBlock(level, new Vector3(pos.x, pos.y, pos.z), state);
}
protected void setBlockAndNotifyAdequately(ChunkManager level, Vector3 pos, Block state) {
setBlock(level, pos, state);
}
protected void setBlock(ChunkManager level, Vector3 v, Block b) {
level.setBlockIdAt((int) v.x, (int) v.y, (int) v.z, b.getId());
level.setBlockDataAt((int) v.x, (int) v.y, (int) v.z, b.getDamage());
}
}
| 942 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
JungleTreePopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/tree/JungleTreePopulator.java | package cn.nukkit.level.generator.populator.tree;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.tree.NewJungleTree;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public class JungleTreePopulator extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public JungleTreePopulator() {
this(BlockSapling.JUNGLE);
}
public JungleTreePopulator(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new NewJungleTree(4 + random.nextBoundedInt(7)).generate(level, random, v.setComponents(x, y, z));
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 1,995 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
DarkOakTreePopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/tree/DarkOakTreePopulator.java | package cn.nukkit.level.generator.populator.tree;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.tree.ObjectDarkOakTree;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public class DarkOakTreePopulator extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public DarkOakTreePopulator() {
this(BlockSapling.DARK_OAK);
}
public DarkOakTreePopulator(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new ObjectDarkOakTree().generate(level, random, v.setComponents(x, y, z));
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 1,981 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
JungleBigTreePopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/tree/JungleBigTreePopulator.java | package cn.nukkit.level.generator.populator.tree;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockLeaves;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.block.BlockWood;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.tree.ObjectJungleBigTree;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public class JungleBigTreePopulator extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public JungleBigTreePopulator() {
this(BlockSapling.JUNGLE);
}
public JungleBigTreePopulator(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new ObjectJungleBigTree(10, 20, new BlockWood(BlockWood.JUNGLE), new BlockLeaves(BlockLeaves.JUNGLE)).generate(this.level, random, v.setComponents(x, y, z));
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 2,140 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
SwampTreePopulator.java | /FileExtraction/Java_unseen/Nukkit_Nukkit/src/main/java/cn/nukkit/level/generator/populator/tree/SwampTreePopulator.java | package cn.nukkit.level.generator.populator.tree;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockSapling;
import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.generator.object.tree.ObjectSwampTree;
import cn.nukkit.level.generator.populator.Populator;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.math.Vector3;
public class SwampTreePopulator extends Populator {
private ChunkManager level;
private int randomAmount;
private int baseAmount;
private final int type;
public SwampTreePopulator() {
this(BlockSapling.OAK);
}
public SwampTreePopulator(int type) {
this.type = type;
}
public void setRandomAmount(int randomAmount) {
this.randomAmount = randomAmount;
}
public void setBaseAmount(int baseAmount) {
this.baseAmount = baseAmount;
}
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new ObjectSwampTree().generate(level, random, v.setComponents(x, y, z));
}
}
private int getHighestWorkableBlock(int x, int z) {
int y;
for (y = 127; y > 0; --y) {
int b = this.level.getBlockIdAt(x, y, z);
if (b == Block.DIRT || b == Block.GRASS) {
break;
} else if (b != Block.AIR && b != Block.SNOW_LAYER) {
return -1;
}
}
return ++y;
}
}
| 1,965 | Java | .java | Nukkit/Nukkit | 821 | 272 | 171 | 2015-05-23T09:51:41Z | 2024-03-21T12:28:05Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.