本文整理匯總了Java中net.minecraftforge.event.entity.EntityJoinWorldEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityJoinWorldEvent.getEntity方法的具體用法?Java EntityJoinWorldEvent.getEntity怎麽用?Java EntityJoinWorldEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.EntityJoinWorldEvent
的用法示例。
在下文中一共展示了EntityJoinWorldEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEntityJoinWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
{
EntityLivingBase entity = (EntityLivingBase) event.getEntity();
World world = entity.getEntityWorld();
IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
if (enemyLevelCap != null && chunkLevelHolder != null)
{
if (enemyLevelCap.getEnemyLevel() == 0)
{
IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
int level = chunkLevel.getChunkLevel();
enemyLevelCap.setEnemyLevel(level);
entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
if (level > 1) setAttributeModifiers(entity, level);
}
}
}
}
示例2: entityJoinedWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void entityJoinedWorld(EntityJoinWorldEvent event)
{
if (playersJoined.contains(event.getEntity().getUniqueID()))
{
EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
logger.info("Sending ID packet to client {}", entity.getName());
PacketHandler.INSTANCE.sendTo(new PacketHandler.ServerIDMessage(updateID), entity);
for (PregenTask task : pregenTasks.values())
{
if (task.preventJoin)
{
kicker.kickPlayer(entity, "Server is still pre-generating!\n" + task.lastPregenString);
logger.error("Kicked player " + entity.getName() + " as still pre-generating");
break;
}
}
playersJoined.remove(entity.getUniqueID());
}
}
示例3: onSpawn
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onSpawn(EntityJoinWorldEvent event) {
if (TF2ConfigVars.targetSentries && event.getEntity() instanceof IMob && event.getEntity() instanceof EntityCreature) {
((EntityCreature)event.getEntity()).targetTasks.addTask(100,
new EntityAINearestAttackableTarget<EntitySentry>((EntityCreature) event.getEntity(), EntitySentry.class, 10, true, false, sentry -> {
return sentry.getOwnerId() != null;
}) {
protected double getTargetDistance()
{
return super.getTargetDistance() * 0.45f;
}
});
}
if (event.getEntity() instanceof EntityPlayer){
if (event.getEntity().world.isRemote) {
if (event.getEntity() == ClientProxy.getLocalPlayer())
TF2weapons.network.sendToServer(new TF2Message.InitClientMessage(TF2weapons.conf));
TF2weapons.network.sendToServer(new TF2Message.ActionMessage(99, (EntityLivingBase) event.getEntity()));
}
if (event.getEntity().world != null && !event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayerMP){
EntityPlayerMP player=((EntityPlayerMP)event.getEntity());
player.inventoryContainer.addListener(new TF2ContainerListener(player));
}
}
}
示例4: checkSpawn
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void checkSpawn (EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntitySlime && !event.getEntity().hasCustomName()) {
for (final TileEntity tile : event.getWorld().loadedTileEntityList) {
if (tile instanceof TileEntityAntiSlime && ((TileEntityAntiSlime) tile).shareChunks((EntityLivingBase) event.getEntity())) {
if (event.getWorld().isBlockPowered(tile.getPos())) {
continue;
}
event.setCanceled(true);
event.getEntity().setDead();
break;
}
}
}
}
示例5: onEntityJoin
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event)
{
Entity entity = event.getEntity();
World world = event.getWorld();
if(entity instanceof EntityItem)
{
ItemStack stack = ((EntityItem) entity).getEntityItem();
if(!stack.isEmpty() && isRottingItem(stack))
{
if(!entity.isDead)
TrackedItemsAdd.add((EntityItem)entity);
}
}
}
示例6: onJoinEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onJoinEvent(EntityJoinWorldEvent event){
if(event.getEntity() == Minecraft.getMinecraft().player) {
if(!event.getEntity().isDead) {
String message = I18n.translateToLocal("chat.join");
message = message.replace("%tag%", I18n.translateToLocal("chat.tag"));
message = message.replace("%loaded%", Layer.getActiveKeys().size()+"");
message = message.replace("%total%", MacroKey.instance.boundKeys.size()+"");
if(MacroKey.instance.configuration.getBoolean("isSpawnMessageEnabled",MacroKey.instance.configuration.CATEGORY_GENERAL, true, "set this to false if you are getting annoyed by the spam")) {
Minecraft.getMinecraft().player.sendChatMessage(message);
}
MacroKey.instance.configuration.save();
}
}
}
示例7: entityJoinWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void entityJoinWorld(EntityJoinWorldEvent event)
{
Entity e = event.getEntity();
if (e instanceof EntityPlayer && !e.getEntityWorld().isRemote)
{
for (String g : giveOnFirstJoin)
{
String tag = MODID + ":givenBook:" + g;
if (!e.getTags().contains(tag))
{
ItemHandlerHelper.giveItemToPlayer((EntityPlayer) e, guidebook.of(new ResourceLocation(g)));
e.addTag(tag);
}
}
}
}
示例8: onEntitySpawn
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event)
{
if(event.getEntity().world.isRemote)
{
Minecraft mc = Minecraft.getMinecraft();
if(event.getEntity() instanceof EntityFishHook)
{
fishHooks.add((EntityFishHook)event.getEntity());
}
if(event.getEntity() instanceof EntityZombie && !(event.getEntity() instanceof EntityZombieVillager) || event.getEntity() instanceof EntitySkeleton || MobAmputation.config.playerGibs == 1 && event.getEntity() instanceof EntityPlayer && event.getEntity() != mc.player)
{
EntityLivingBase living = (EntityLivingBase)event.getEntity();
if(!amputationMap.containsKey(living) && !living.isChild())
{
attachGibs(event.getEntity().world, living);
}
}
}
}
示例9: PlayerJoinedWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
/**
* This event is used to determine if the player should be given the starting house item when they log in.
* @param event The event object.
*/
@SubscribeEvent
public static void PlayerJoinedWorld(EntityJoinWorldEvent event)
{
if (!event.getWorld().isRemote && event.getEntity() instanceof EntityPlayerMP)
{
System.out.println("Player joined world, checking to see if the house builder should be provided.");
EntityPlayerMP player = (EntityPlayerMP)event.getEntity();
EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData((EntityPlayerMP)event.getEntity());
if (!playerConfig.givenHouseBuilder && Prefab.proxy.proxyConfiguration.addHouseItem)
{
ItemStack stack = Prefab.proxy.proxyConfiguration.addModerateHouseInstead ? new ItemStack(ModRegistry.ModerateHouse()) : new ItemStack(ModRegistry.StartHouse());
player.inventory.addItemStackToInventory(stack);
player.inventoryContainer.detectAndSendChanges();
// Make sure to set the tag for this player so they don't get the item again.
playerConfig.givenHouseBuilder = true;
playerConfig.saveToPlayer(player);
}
// Send the persist tag to the client.
Prefab.network.sendTo(new PlayerEntityTagMessage(playerConfig.getModIsPlayerNewTag(player)), player);
}
}
示例10: onJoinWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event)
{
if (event.getEntity() instanceof EntityPlayer && !event.getEntity().getEntityData().hasKey("hasSpawned"))
{
/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/
//((EntityPlayer)event.getEntity()).getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1000);
//((EntityPlayer)event.getEntity()).setHealth(1000);
event.getEntity().getEntityData().setBoolean("hasSpawned", true);
}
if (event.getEntity() instanceof EntityPlayer)
{
/*if(!(((EntityPlayer)event.getEntity()).inventory instanceof InventoryPlayerTFC))
((EntityPlayer)event.getEntity()).inventory = Core.getNewInventory((EntityPlayer)event.getEntity());*/
((EntityPlayer)event.getEntity()).inventoryContainer = new ContainerPlayerTFC(((EntityPlayer)event.getEntity()).inventory, !event.getWorld().isRemote, (EntityPlayer)event.getEntity());
((EntityPlayer)event.getEntity()).openContainer = ((EntityPlayer)event.getEntity()).inventoryContainer;
if(!event.getWorld().isRemote)
{
TFC.network.sendTo(new CFoodPacket((IFoodStatsTFC)((EntityPlayer)event.getEntity()).getFoodStats()), (EntityPlayerMP)event.getEntity());
}
}
}
示例11: applyForgeEventPatch
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@Override
public <T extends Event> boolean applyForgeEventPatch(T e) {
EntityJoinWorldEvent event = (EntityJoinWorldEvent) e;
EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
AppliedPatches patches = PatchManager.instance().getAppliedPatchesForPlayer(player);
if (player.connection.player == event.getEntity() && !(player.connection instanceof NetHandlerPlayServer)) {
net.minecraft.network.NetHandlerPlayServer handler = player.connection;
player.connection = new NetHandlerPlayServer(player.getServer(), handler.netManager, handler.player);
if (patches != null)
patches.setPatchSuccessfullyApplied(this.displayName, true);
}
return true;
}
示例12: sendAlert
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void sendAlert(EntityJoinWorldEvent event) {
if (!(event.getEntity() instanceof EntityCreeper)) {
return;
}
List players = event.getEntity().worldObj.playerEntities;
for (int i = 0; i < players.size(); i++) {
EntityPlayer player = (EntityPlayer) players.get(i);
if (event.getWorld().isRemote) {
player.addChatComponentMessage(new TextComponentString(
TextFormatting.GREEN + "A creeper has spawned!"));
}
}
}
示例13: onPlayerLogin
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onPlayerLogin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
AllomancyCapability cap = AllomancyCapability.forPlayer(player);
Registry.network.sendTo(new AllomancyCapabilityPacket(cap, event.getEntity().getEntityId()), player);
if (cap.getAllomancyPower() >= 0) {
Registry.network.sendTo(new AllomancyCapabilityPacket(cap, player.getEntityId()), player);
} else if (AllomancyConfig.randomizeMistings && cap.getAllomancyPower() == -1) {
int randomMisting = (int) (Math.random() * 8);
cap.setAllomancyPower(randomMisting);
Registry.network.sendTo(new AllomancyPowerPacket(randomMisting), player);
ItemStack dust = new ItemStack(Item.getByNameOrId("allomancy:flake" + Registry.flakeMetals[randomMisting]));
// Give the player one flake of their metal
if (!player.inventory.addItemStackToInventory(dust)) {
EntityItem entity = new EntityItem(event.getEntity().getEntityWorld(), player.posX, player.posY, player.posZ, dust);
event.getEntity().getEntityWorld().spawnEntity(entity);
}
}
}
}
示例14: onJoin
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onJoin(EntityJoinWorldEvent event) {
if (!event.getWorld().isRemote) {
if (event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
if (names.contains(player.getDisplayName())) {
ItemStack potato = new ItemStack(Items.POISONOUS_POTATO);
potato.addEnchantment(Enchantments.UNBREAKING, 1);
potato.setStackDisplayName("Death Potato");
if (!player.inventory.hasItemStack(potato)) {
player.inventory.addItemStackToInventory(potato);
}
}
}
}
}
示例15: onEntityJoin
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //導入方法依賴的package包/類
/**
* Crash the game if our inventory has been replaced by something else, or the coremod failed
* Also synchronize battle inventory
* @param event that spawned the player
*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityJoin(EntityJoinWorldEvent event){
if (isValid(event.getEntity())) {
if (!(((EntityPlayer) event.getEntity()).inventory instanceof InventoryPlayerBattle) && !MinecraftForge.EVENT_BUS.post(new InventoryExceptionEvent((EntityPlayer)event.getEntity()))) {
throw new RuntimeException("Player inventory has been replaced with " + ((EntityPlayer) event.getEntity()).inventory.getClass() + " which is incompatible with Mine & Blade:Battlegear.");
}
if(event.getEntity() instanceof EntityPlayerMP){
Battlegear.packetHandler.sendPacketToPlayer(
new BattlegearSyncItemPacket((EntityPlayer) event.getEntity()).generatePacket(),
(EntityPlayerMP) event.getEntity());
}
}
if (event.getEntity() instanceof EntityLivingBase) {
((EntityLivingBase) event.getEntity()).getEntityAttribute(Attributes.daze).setBaseValue(0);
}
}