net.minecraft.entity.passive.EntityTameable Java Examples
The following examples show how to use
net.minecraft.entity.passive.EntityTameable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HackableHandler.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static void addDefaultEntries(){ PneumaticRegistry.getInstance().addHackable(Blocks.tnt, HackableTNT.class); PneumaticRegistry.getInstance().addHackable(Blocks.mob_spawner, HackableMobSpawner.class); PneumaticRegistry.getInstance().addHackable(Blocks.lever, HackableLever.class); PneumaticRegistry.getInstance().addHackable(Blocks.stone_button, HackableButton.class); PneumaticRegistry.getInstance().addHackable(Blocks.wooden_button, HackableButton.class); PneumaticRegistry.getInstance().addHackable(Blocks.wooden_door, HackableDoor.class); PneumaticRegistry.getInstance().addHackable(Blocks.tripwire_hook, HackableTripwire.class); PneumaticRegistry.getInstance().addHackable(Blocks.dispenser, HackableDispenser.class); PneumaticRegistry.getInstance().addHackable(Blocks.dropper, HackableDispenser.class); PneumaticRegistry.getInstance().addHackable(Blockss.securityStation, HackableSecurityStation.class); PneumaticRegistry.getInstance().addHackable(Blocks.monster_egg, HackableTripwire.class); PneumaticRegistry.getInstance().addHackable(Blocks.noteblock, HackableNoteblock.class); PneumaticRegistry.getInstance().addHackable(Blocks.jukebox, HackableJukebox.class); PneumaticRegistry.getInstance().addHackable(EntityCreeper.class, HackableCreeper.class); PneumaticRegistry.getInstance().addHackable(EntityTameable.class, HackableTameable.class); PneumaticRegistry.getInstance().addHackable(EntityCow.class, HackableCow.class); PneumaticRegistry.getInstance().addHackable(EntityCaveSpider.class, HackableCaveSpider.class); PneumaticRegistry.getInstance().addHackable(EntityBlaze.class, HackableBlaze.class); PneumaticRegistry.getInstance().addHackable(EntityGhast.class, HackableGhast.class); PneumaticRegistry.getInstance().addHackable(EntityWitch.class, HackableWitch.class); PneumaticRegistry.getInstance().addHackable(EntityLiving.class, HackableLivingDisarm.class); PneumaticRegistry.getInstance().addHackable(EntityEnderman.class, HackableEnderman.class); PneumaticRegistry.getInstance().addHackable(EntityBat.class, HackableBat.class); }
Example #2
Source File: EntityTameableMetaProvider.java From OpenPeripheral-Integration with MIT License | 5 votes |
@Override public Object getMeta(EntityTameable target, Vec3 relativePos) { Map<String, Object> map = Maps.newHashMap(); boolean isTamed = target.isTamed(); map.put("isTamed", isTamed); if (isTamed) { map.put("isSitting", target.isSitting()); map.put("ownerUUID", target.func_152113_b()); } return map; }
Example #3
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds the persistenceRequired flag to entities, if they need it in order to not despawn. * The checks are probably at most accurate for vanilla entities. * @param livingBase * @return */ public static boolean applyMobPersistence(EntityLiving living) { if (living.isNoDespawnRequired() == false) { boolean canDespawn = ((living instanceof EntityMob) && living.isNonBoss()) || (living instanceof EntityWaterMob) || ((living instanceof EntityTameable) && ((EntityTameable)living).isTamed() == false); if (canDespawn == false) { try { canDespawn = (boolean) methodHandle_EntityLiving_canDespawn.invokeExact(living); } catch (Throwable t) { EnderUtilities.logger.warn("Error while trying to invoke EntityLiving.canDespawn() on entity '{}' via a MethodHandle", living, t); } } if (canDespawn) { // Sets the persistenceRequired boolean living.enablePersistence(); living.getEntityWorld().playSound(null, living.getPosition(), Sounds.JAILER, SoundCategory.MASTER, 0.8f, 1.2f); return true; } } return false; }
Example #4
Source File: EntityTrackHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void addInfo(Entity entity, List<String> curInfo){ EntityLivingBase owner = ((EntityTameable)entity).getOwner(); if(owner != null) { curInfo.add("Owner: " + owner.getCommandSenderName()); } else { curInfo.add("This animal can be tamed"); } }
Example #5
Source File: HackableTameable.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onHackFinished(Entity entity, EntityPlayer player){ EntityTameable tameable = (EntityTameable)entity; if(entity.worldObj.isRemote) { tameable.handleHealthUpdate((byte)7); } else { tameable.setPathToEntity((PathEntity)null); tameable.setAttackTarget((EntityLivingBase)null); tameable.setHealth(20.0F); tameable.func_152115_b(player.getUniqueID().toString());//setOwner entity.worldObj.setEntityState(tameable, (byte)7); tameable.setTamed(true); } }
Example #6
Source File: CraftTameableAnimal.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftTameableAnimal(CraftServer server, EntityTameable entity) { super(server, entity); }
Example #7
Source File: CraftTameableAnimal.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityTameable getHandle() { return (EntityTameable) super.getHandle(); }
Example #8
Source File: KillauraHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onUpdate(WUpdateEvent event) { EntityPlayerSP player = event.getPlayer(); World world = WPlayer.getWorld(player); if(player.getCooledAttackStrength(0) < 1) return; double rangeSq = Math.pow(range.getValue(), 2); Stream<EntityLivingBase> stream = world.loadedEntityList .parallelStream().filter(e -> e instanceof EntityLivingBase) .map(e -> (EntityLivingBase)e) .filter(e -> !e.isDead && e.getHealth() > 0) .filter(e -> WEntity.getDistanceSq(player, e) <= rangeSq) .filter(e -> e != player) .filter(e -> !(e instanceof EntityFakePlayer)); if(filterPlayers.isChecked()) stream = stream.filter(e -> !(e instanceof EntityPlayer)); if(filterSleeping.isChecked()) stream = stream.filter(e -> !(e instanceof EntityPlayer && ((EntityPlayer)e).isPlayerSleeping())); if(filterFlying.getValue() > 0) stream = stream.filter(e -> { if(!(e instanceof EntityPlayer)) return true; AxisAlignedBB box = e.getEntityBoundingBox(); box = box.union(box.offset(0, -filterFlying.getValue(), 0)); // Using expand() with negative values doesn't work in 1.10.2. return world.collidesWithAnyBlock(box); }); if(filterMonsters.isChecked()) stream = stream.filter(e -> !(e instanceof IMob)); if(filterPigmen.isChecked()) stream = stream.filter(e -> !(e instanceof EntityPigZombie)); if(filterEndermen.isChecked()) stream = stream.filter(e -> !(e instanceof EntityEnderman)); if(filterAnimals.isChecked()) stream = stream.filter(e -> !(e instanceof EntityAnimal || e instanceof EntityAmbientCreature || e instanceof EntityWaterMob)); if(filterBabies.isChecked()) stream = stream.filter(e -> !(e instanceof EntityAgeable && ((EntityAgeable)e).isChild())); if(filterPets.isChecked()) stream = stream .filter(e -> !(e instanceof EntityTameable && ((EntityTameable)e).isTamed())) .filter(e -> !WEntity.isTamedHorse(e)); if(filterVillagers.isChecked()) stream = stream.filter(e -> !(e instanceof EntityVillager)); if(filterGolems.isChecked()) stream = stream.filter(e -> !(e instanceof EntityGolem)); if(filterInvisible.isChecked()) stream = stream.filter(e -> !e.isInvisible()); target = stream.min(priority.getSelected().comparator).orElse(null); if(target == null) return; RotationUtils .faceVectorPacket(target.getEntityBoundingBox().getCenter()); mc.playerController.attackEntity(player, target); player.swingArm(EnumHand.MAIN_HAND); }
Example #9
Source File: PlayerEventHandler.java From GriefPrevention with MIT License | 4 votes |
@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(); } }
Example #10
Source File: AIFollowOwner.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public AIFollowOwner(EntityTameable entity, float minDist, float maxDist) { super(entity, 0, minDist, maxDist); this.entity = entity; }
Example #11
Source File: ItemPetContract.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand) { if (target instanceof EntityTameable) { if (player.getEntityWorld().isRemote == false) { if (this.isSigned(stack)) { UUID targetOwner = ((EntityTameable) target).getOwnerId(); UUID signedOwner = this.getOwnerUUID(stack); // This contract is signed by the current owner of the target, // and the contract is for this target entity, and the player is not the owner // -> change the owner of the target. if (targetOwner != null && targetOwner.equals(signedOwner) && target.getUniqueID().equals(this.getSubjectUUID(stack)) && player.getUniqueID().equals(signedOwner) == false) { ((EntityTameable) target).setTamed(true); ((EntityTameable) target).setOwnerId(player.getUniqueID()); // See EntityTameable#handleStatusUpdate() player.getEntityWorld().setEntityState(target, (byte) 7); stack.shrink(1); } } // Blank contract - if the target is tamed, and owned by the player, sign the contract else { if (((EntityTameable) target).isTamed() && ((EntityTameable) target).isOwner(player)) { ItemStack stackSigned = stack.copy(); stackSigned.setCount(1); this.signContract(stackSigned, player, target); if (player.addItemStackToInventory(stackSigned) == false) { player.dropItem(stackSigned, false); } stack.shrink(1); } } } return true; } return super.itemInteractionForEntity(stack, player, target, hand); }
Example #12
Source File: EntityTrackHandler.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isApplicable(Entity entity){ return entity instanceof EntityTameable; }
Example #13
Source File: HackableTameable.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean canHack(Entity entity, EntityPlayer player){ return ((EntityTameable)entity).getOwner() != player; }