Java源码示例:net.minecraft.entity.passive.EntityHorse
示例1
public BiomeMeadow() {
super(properties);
decorator.treesPerChunk = 0;
decorator.extraTreeChance = 0.2F;
decorator.flowersPerChunk = 15;
decorator.grassPerChunk = 15;
decorator.reedsPerChunk = 2;
spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 5, 2, 4));
spawnableCreatureList.add(new SpawnListEntry(EntityDonkey.class, 1, 1, 2));
this.flowers.clear();
for (BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
if (type.getBlockType() == BlockFlower.EnumFlowerColor.YELLOW)
continue;
if (type == BlockFlower.EnumFlowerType.BLUE_ORCHID)
type = BlockFlower.EnumFlowerType.POPPY;
addFlower(net.minecraft.init.Blocks.RED_FLOWER.getDefaultState().withProperty(net.minecraft.init.Blocks.RED_FLOWER.getTypeProperty(), type), 10);
}
}
示例2
public BiomeMeadow() {
super(properties);
decorator.treesPerChunk = 0;
decorator.extraTreeChance = 0.2F;
decorator.flowersPerChunk = 15;
decorator.grassPerChunk = 15;
decorator.reedsPerChunk = 2;
spawnableCreatureList.add(new SpawnListEntry(EntityHorse.class, 5, 2, 4));
spawnableCreatureList.add(new SpawnListEntry(EntityDonkey.class, 1, 1, 2));
this.flowers.clear();
for (BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) {
if (type.getBlockType() == BlockFlower.EnumFlowerColor.YELLOW)
continue;
if (type == BlockFlower.EnumFlowerType.BLUE_ORCHID)
type = BlockFlower.EnumFlowerType.POPPY;
addFlower(net.minecraft.init.Blocks.RED_FLOWER.getDefaultState().withProperty(net.minecraft.init.Blocks.RED_FLOWER.getTypeProperty(), type), 10);
}
}
示例3
@SubscribeEvent
public void handleHorseMove(LivingUpdateEvent event)
{
EntityLivingBase e = event.getEntityLiving();
if (e instanceof EntityHorse)
{
EntityHorse horse = (EntityHorse) e;
for (Entity pass : horse.getPassengers())
{
if (pass instanceof EntityLivingBase && CyberwareAPI.isCyberwareInstalled(pass, new ItemStack(this, 1, 0)))
{
horse.addPotionEffect(new PotionEffect(MobEffects.SPEED, 1, 5, true, false));
break;
}
}
}
}
示例4
@Override
public Object getMeta(EntityHorse target, Vec3 relativePos) {
Map<String, Object> map = Maps.newHashMap();
map.put("eatingHaystack", target.isEatingHaystack());
map.put("hasReproduced", target.getHasReproduced());
map.put("bred", target.func_110205_ce());
map.put("horseType", target.getHorseType());
map.put("horseVariant", target.getHorseVariant());
map.put("horseTemper", target.getTemper());
map.put("horseTame", target.isTame());
map.put("ownerUUID", target.func_152119_ch());
final boolean chested = target.isChested();
map.put("chestedHorse", chested);
if (chested) {
IInventory invent = HORSE_CHEST.get(target);
map.put("chest", InventoryMetaProvider.wrapToProxyTable(invent));
}
return map;
}
示例5
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
stack.damageItem(1, player);
if (victim instanceof EntityHorse || victim instanceof EntityPig)
victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 5));
else if (victim instanceof EntityPlayer || victim instanceof EntityGolem) {
victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 1));
victim.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 200, 1));
victim.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1));
}
if (!player.worldObj.isRemote && !Config.noLust && player.worldObj.provider.dimensionId == -1 && player.worldObj.rand.nextInt(15) == 1) {
EntityItem ent = victim.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
}
return true;
}
示例6
private boolean isAnimal(EntityLivingBase victim) {
return victim instanceof EntityCow ||
victim instanceof EntityHorse ||
victim instanceof EntityPig ||
victim instanceof EntityDonkey ||
victim instanceof EntityChicken ||
victim instanceof EntitySheep;
}
示例7
@Override
protected ResourceLocation getEntityTexture(EntityHorse horse) {
if(horse.getTotalArmorValue() == 0) {
return zombieHorseTexture;
} else {
return getArmoredTexture(horse);
}
}
示例8
public BiomeRockyPlains() {
super(false, properties);
this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityHorse.class, 4, 1, 5));
this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityDonkey.class, 1, 1, 2));
}
示例9
public CraftHorse(CraftServer server, EntityHorse entity) {
super(server, entity);
}
示例10
@Override
public EntityHorse getHandle() {
return (EntityHorse) super.getHandle();
}
示例11
public void setJumpStrength(double strength) {
Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero");
getHandle().getEntityAttribute(EntityHorse.JUMP_STRENGTH).setBaseValue(strength);
}
示例12
public static boolean isTamedHorse(Entity e)
{
return e instanceof EntityHorse && ((EntityHorse)e).isTame();
}
示例13
public BiomeRockyPlains() {
super(false, properties);
this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityHorse.class, 4, 1, 5));
this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityDonkey.class, 1, 1, 2));
}
示例14
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractEntity(InteractEntityEvent.Secondary event, @First Player player) {
if (!GPFlags.INTERACT_ENTITY_SECONDARY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
final Entity targetEntity = event.getTargetEntity();
final HandType handType = event.getHandType();
final ItemStack itemInHand = player.getItemInHand(handType).orElse(ItemStack.empty());
final Object source = !itemInHand.isEmpty() ? itemInHand : player;
if (GriefPreventionPlugin.isTargetIdBlacklisted(ClaimFlag.INTERACT_ENTITY_SECONDARY.toString(), targetEntity, player.getWorld().getProperties())) {
return;
}
GPTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.startTimingIfSync();
Location<World> location = targetEntity.getLocation();
GPClaim claim = this.dataStore.getClaimAt(location);
GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
// if entity is living and has an owner, apply special rules
if (targetEntity instanceof Living) {
EntityBridge spongeEntity = (EntityBridge) targetEntity;
Optional<User> owner = ((OwnershipTrackedBridge) spongeEntity).tracked$getOwnerReference();
if (owner.isPresent()) {
UUID ownerID = owner.get().getUniqueId();
// if the player interacting is the owner or an admin in ignore claims mode, always allow
if (player.getUniqueId().equals(ownerID) || playerData.canIgnoreClaim(claim)) {
// if giving away pet, do that instead
if (playerData.petGiveawayRecipient != null) {
SpongeEntityType spongeEntityType = (SpongeEntityType) ((Entity) spongeEntity).getType();
if (spongeEntityType.equals(EntityTypes.UNKNOWN) || !spongeEntityType.getModId().equalsIgnoreCase("minecraft")) {
final Text message = GriefPreventionPlugin.instance.messageData.commandPetInvalid
.apply(ImmutableMap.of(
"type", spongeEntityType.getId())).build();
GriefPreventionPlugin.sendMessage(player, message);
playerData.petGiveawayRecipient = null;
GPTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
return;
}
((Entity) spongeEntity).setCreator(playerData.petGiveawayRecipient.getUniqueId());
if (targetEntity instanceof EntityTameable) {
EntityTameable tameable = (EntityTameable) targetEntity;
tameable.setOwnerId(playerData.petGiveawayRecipient.getUniqueId());
} else if (targetEntity instanceof EntityHorse) {
EntityHorse horse = (EntityHorse) targetEntity;
horse.setOwnerUniqueId(playerData.petGiveawayRecipient.getUniqueId());
horse.setHorseTamed(true);
}
playerData.petGiveawayRecipient = null;
GriefPreventionPlugin.sendMessage(player, GriefPreventionPlugin.instance.messageData.commandPetConfirmation.toText());
event.setCancelled(true);
this.sendInteractEntityDenyMessage(itemInHand, targetEntity, claim, player, handType);
}
GPTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
return;
}
}
}
if (playerData.canIgnoreClaim(claim)) {
GPTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
return;
}
Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INTERACT_ENTITY_SECONDARY, source, targetEntity, player, TrustType.ACCESSOR, true);
if (result == Tristate.TRUE && targetEntity instanceof ArmorStand) {
result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INVENTORY_OPEN, source, targetEntity, player, TrustType.CONTAINER, false);
}
if (result == Tristate.FALSE) {
event.setCancelled(true);
this.sendInteractEntityDenyMessage(itemInHand, targetEntity, claim, player, handType);
GPTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
}
}
示例15
public CraftHorse(CraftServer server, EntityHorse entity) {
super(server, entity);
}
示例16
@Override
public EntityHorse getHandle() {
return (EntityHorse) entity;
}
示例17
public void setJumpStrength(double strength) {
Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero");
getHandle().getEntityAttribute(EntityHorse.horseJumpStrength).setBaseValue(strength);
}
示例18
@Override
public Render<? super EntityHorse> createRenderFor(RenderManager manager) {
return new RenderFallenMount(manager);
}