本文整理汇总了Java中org.spongepowered.api.entity.living.animal.Animal类的典型用法代码示例。如果您正苦于以下问题:Java Animal类的具体用法?Java Animal怎么用?Java Animal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Animal类属于org.spongepowered.api.entity.living.animal包,在下文中一共展示了Animal类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onInteractEvent
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onInteractEvent(InteractEntityEvent.Secondary e, @First Player p){
Entity et = e.getTargetEntity();
Location<World> l = et.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
RedProtect.get().logger.debug("entity","RPEntityListener - InteractEntityEvent.Secondary entity "+et.getType().getName());
if (r != null && !r.canInteractPassives(p) && (et instanceof Animal || et instanceof Villager || et instanceof Golem || et instanceof Ambient)) {
if (RedProtect.get().getPVHelper().checkHorseOwner(et, p)){
return;
}
e.setCancelled(true);
RPLang.sendMessage(p, "entitylistener.region.cantinteract");
}
}
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPEntityListener.java
示例2: onEntityCollide
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Listener
public void onEntityCollide(CollideEntityEvent event) {
boolean canActivate = System.currentTimeMillis() - lastActivation >= TimeUnit.MILLISECONDS.toMillis(500);
if (!canActivate) {
return;
}
List<Entity> entities = event.getEntities().stream().filter(e -> e instanceof Animal).collect(Collectors.toList());
if (entities.size() <= 5) {
return;
}
lastActivation = System.currentTimeMillis();
Probability.pickOneOf(entities).damage(1, DamageSources.GENERIC);
}
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:MobDensityListener.java
示例3: onEntityDrop
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Listener
public void onEntityDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) EntitySpawnCause spawnCause) {
Entity entity = spawnCause.getEntity();
if (!(entity instanceof Animal)) {
return;
}
Optional<TheButcherShopInstance> optInst = manager.getApplicableZone(entity);
if (!optInst.isPresent()) {
return;
}
event.getEntities().clear();
Item item = (Item) entity.getLocation().createEntity(EntityTypes.ITEM);
item.offer(Keys.REPRESENTED_ITEM, newItemStack("skree:unpackaged_meat").createSnapshot());
event.getEntities().add(item);
}
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:TheButcherShopListener.java
示例4: shakeHidingAnimals
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
public void shakeHidingAnimals() {
getContained(Animal.class).stream().filter((animal) -> {
int relativeYPosition = animal.getLocation().getPosition().getFloorY() - getRegion().getMinimumPoint().getY();
return relativeYPosition > 9;
}).forEach((animal) -> {
animal.setVelocity(new Vector3d(
Probability.getRangedRandom(-1, 1),
0,
Probability.getRangedRandom(-1, 1)
));
});
}
开发者ID:Skelril,项目名称:Skree,代码行数:13,代码来源:TheButcherShopInstance.java
示例5: countEntities
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Override
public int[] countEntities(Plot plot) {
Location pos1 = plot.getBottomAbs();
Location pos2 = plot.getTopAbs();
World world = SpongeUtil.getWorld(pos1.getWorld());
int bx = pos1.getX();
int bz = pos1.getZ();
int tx = pos2.getX();
int tz = pos2.getZ();
int[] count = new int[6];
world.getEntities(entity -> {
org.spongepowered.api.world.Location loc = entity.getLocation();
int x = loc.getBlockX();
if ((x >= bx) && (x <= tx)) {
int z = loc.getBlockZ();
if ((z >= bz) && (z <= tz)) {
count[0]++;
if (entity instanceof Living) {
count[3]++;
if (entity instanceof Animal) {
count[1]++;
} else if (entity instanceof Monster) {
count[2]++;
}
} else {
count[4]++;
}
}
}
return false;
});
return count;
}
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:35,代码来源:SpongeChunkManager.java
示例6: onAnimalDeath
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
public void onAnimalDeath(DestructEntityEvent.Death event, @Root Player player, @Getter("getTargetEntity") Animal animal) {
Point.Builder p = newPoint("animal_death");
addPlayer(p, player);
EntityType type = animal.getType();
p.tag("animal_type", type.getId());
p.addField("animal_name", type.getName());
addLocation(p, animal.getLocation());
connection.write(p.build());
}
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:Stats.java
示例7: run
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Override
public void run() {
// apply changes to the world, but ONLY to unclaimed blocks
// note that the edge of the results is not applied (the 1-block-wide
// band around the outside of the chunk)
// those data were sent to the processing thread for reference
// purposes, but aren't part of the area selected for restoration
for (int x = 1; x < this.snapshots.length - 1; x++) {
for (int z = 1; z < this.snapshots[0][0].length - 1; z++) {
for (int y = this.miny; y < this.snapshots[0].length; y++) {
BlockSnapshot blockUpdate = this.snapshots[x][y][z];
BlockState currentBlock = blockUpdate.getLocation().get().getBlock();
int originalMeta = BlockUtils.getBlockStateMeta(blockUpdate.getState());
int newMeta = BlockUtils.getBlockStateMeta(currentBlock);
if (!blockUpdate.getState().getType().equals(currentBlock.getType()) || originalMeta != newMeta) {
blockUpdate.restore(true, BlockChangeFlags.PHYSICS);
}
}
}
}
// clean up any entities in the chunk, ensure no players are suffocated
Optional<Chunk> chunk = this.lesserCorner.getExtent().getChunk(this.lesserCorner.getBlockX() >> 4, 0, this.lesserCorner.getBlockZ() >> 4);
if (chunk.isPresent()) {
try (final CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
Sponge.getCauseStackManager().pushCause(GriefPreventionPlugin.instance);
for (Entity entity : chunk.get().getEntities()) {
if (!(entity instanceof Player || entity instanceof Animal)) {
// hanging entities (paintings, item frames) are protected when they're in land claims
if (!(entity instanceof Hanging)
|| GriefPreventionPlugin.instance.dataStore.getClaimAt(entity.getLocation()) == null) {
// everything else is removed
entity.remove();
}
}
// for players, always ensure there's air where the player is standing
else {
entity.getLocation().setBlock(BlockTypes.AIR.getDefaultState());
entity.getLocation().getRelative(Direction.UP).setBlock(BlockTypes.AIR.getDefaultState());
}
}
}
}
// show visualization to player who started the restoration
if (player != null) {
GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
GPClaim claim = new GPClaim(this.lesserCorner, this.greaterCorner, ClaimType.BASIC, false);
// TODO
claim.getVisualizer().resetVisuals();
claim.getVisualizer().createClaimBlockVisuals(player.getLocation().getBlockY(), player.getLocation(), playerData);
claim.getVisualizer().apply(player);
}
}
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:56,代码来源:RestoreNatureExecutionTask.java
示例8: remove
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Override
public void remove() {
remove(Monster.class, Animal.class, ExperienceOrb.class, Item.class, Arrow.class);
}
开发者ID:Skelril,项目名称:Skree,代码行数:5,代码来源:TheButcherShopInstance.java
示例9: of
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
public static PoreTameable of(Animal handle) {
return WrapperConverter.of(PoreTameable.class, handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreTameable.java
示例10: PoreTameable
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
protected PoreTameable(Animal handle) {
super(handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreTameable.java
示例11: of
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
public static PoreAnimals of(Animal handle) {
return WrapperConverter.of(PoreAnimals.class, handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreAnimals.java
示例12: PoreAnimals
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
protected PoreAnimals(Animal handle) {
super(handle);
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreAnimals.java
示例13: getHandle
import org.spongepowered.api.entity.living.animal.Animal; //导入依赖的package包/类
@Override
public Animal getHandle() {
return (Animal) super.getHandle();
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PoreAnimals.java
注:本文中的org.spongepowered.api.entity.living.animal.Animal类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论