本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerEvent類的典型用法代碼示例。如果您正苦於以下問題:Java PlayerEvent類的具體用法?Java PlayerEvent怎麽用?Java PlayerEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PlayerEvent類屬於net.minecraftforge.event.entity.player包,在下文中一共展示了PlayerEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playerClone
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void playerClone(PlayerEvent.Clone event)
{
IStats oldStats = getStats(event.getOriginal());
IStats newStats = getStats(event.getEntityLiving());
if (newStats != null && oldStats != null)
{
newStats.setMana(oldStats.getMana());
newStats.setMaxMana(oldStats.getMaxMana());
newStats.setManaPerSecond(oldStats.getManaPerSecond());
newStats.setMagicalPower(oldStats.getMagicalPower());
newStats.setHealthPerSecond(oldStats.getHealthPerSecond());
newStats.setCriticalChance(oldStats.getCriticalChance());
newStats.setCriticalDamage(oldStats.getCriticalDamage());
}
}
示例2: onClientLogIn
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onClientLogIn(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event)
{
// Should be always true but mods can throw this event at any time...
if (event.player instanceof EntityPlayerMP)
{
if (FMLCommonHandler.instance().getMinecraftServerInstance().isDedicatedServer())
{
SettingsManager.restoreAllClientData();
}
else
{
SettingsManager.sendSettingsToClient((EntityPlayerMP) event.player);
}
}
}
示例3: onPlayerLoadFromFileEvent
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerLoadFromFileEvent(PlayerEvent.LoadFromFile event) {
if (!EtFuturum.enableEnchants)
return;
try {
File file = event.getPlayerFile(Reference.MOD_ID);
if (!file.exists()) {
file.createNewFile();
return;
}
BufferedReader br = new BufferedReader(new FileReader(file));
String line = br.readLine();
if (line != null) {
int seed = Integer.parseInt(line);
ContainerEnchantment.seeds.put(event.playerUUID, seed);
br.close();
}
} catch (Exception e) {
}
}
示例4: onPlayerSaveFromFileEvent
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerSaveFromFileEvent(PlayerEvent.SaveToFile event) {
if (!EtFuturum.enableEnchants)
return;
try {
File file = event.getPlayerFile(Reference.MOD_ID);
if (!file.exists()) {
file.createNewFile();
return;
}
Integer seed = ContainerEnchantment.seeds.get(event.playerUUID);
if (seed != null) {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
bw.write(seed.toString());
bw.close();
}
} catch (IOException e) {
}
}
示例5: onPlayerClone
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event)
{
PlayerTracker tracker = TrackerManager.lookupTracker(event.original);
if (tracker != null) {
HazardsLib.modLog.info("Changing tracker owner for: '" + event.entity.getCommandSenderName() + "'...");
tracker.owner = event.entityPlayer;
if (event.wasDeath) {
tracker.resetData();
TrackerManager.saveTracker(tracker);
}
tracker.loadFromNBT();
}
if (event.wasDeath) {
doDeath(event.entityPlayer);
doDeath(event.original);
}
}
示例6: checkPlayerNBT
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkPlayerNBT(PlayerEvent.Clone event) {
if (!event.isWasDeath())
return;
EntityPlayer old = event.getOriginal();
EntityPlayer player = event.getEntityPlayer();
NBTTagCompound oldtag = old.getEntityData();
NBTTagCompound tag = player.getEntityData();
if (oldtag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) {
tag.setTag(GrowthSteps.TAG_GROWTHSTAGES, oldtag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10).copy());
}
if (oldtag.hasKey("hasSacrificed"))
tag.setBoolean("hasSacrificed", oldtag.getBoolean("hasSacrificed"));
if (oldtag.hasKey(SeedBehavior.TAG_ABSTRACT))
tag.setInteger(SeedBehavior.TAG_ABSTRACT, oldtag.getInteger(SeedBehavior.TAG_ABSTRACT));
}
示例7: playerName
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void playerName(PlayerEvent.NameFormat event) {
if(Minecraft.getMinecraft().player != null && WeaponsCapability.get(event.getEntityPlayer()).isDisguised()) {
String username=WeaponsCapability.get(event.getEntityPlayer()).getDisguiseType().substring(2);
if(TF2Util.isOnSameTeam(Minecraft.getMinecraft().player, event.getEntityPlayer())) {
event.setDisplayname(event.getDisplayname()+" ["+username+"]");
}
else {
if(WeaponsCapability.get(event.getEntityPlayer()).getDisguiseType().startsWith("M:")) {
if(event.getEntityPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).entityDisguise != null){
event.setDisplayname(TextFormatting.RESET+event.getEntityPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).entityDisguise.getDisplayName().getFormattedText());
}
else
event.setDisplayname(TextFormatting.RESET+I18n.format("entity."+username+".name"));
}
else
event.setDisplayname(ScorePlayerTeam.formatPlayerName(Minecraft.getMinecraft().world.getScoreboard().getPlayersTeam(username), username));
}
}
}
示例8: craftItem
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void craftItem(net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event) {
ItemStack withPattern=ItemStack.EMPTY;
ItemStack noPattern=ItemStack.EMPTY;
for(int i=0; i<event.craftMatrix.getSizeInventory();i++){
ItemStack stack=event.craftMatrix.getStackInSlot(i);
if(!stack.isEmpty() && stack.getItem() instanceof ItemBanner){
if(TileEntityBanner.getPatterns(stack)>0){
withPattern=stack;
}
else{
noPattern=stack;
}
if(!withPattern.isEmpty()&&!noPattern.isEmpty()){
withPattern.shrink(1);
}
}
}
}
示例9: persistSoulDrain
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void persistSoulDrain(final PlayerEvent.Clone event) {
if (event.entityPlayer.worldObj.isRemote || ExtraUtils.permaSoulDrainOff) {
return;
}
final EntityPlayer original = event.original;
EntityPlayer clone = event.entityPlayer;
AttributeModifier attr = original.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).getModifier(ItemSoul.uuid);
if (attr == null) {
attr = clone.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).getModifier(ItemSoul.uuid);
if (attr != null) {
clone = event.original;
}
}
if (attr != null) {
try {
clone.getAttributeMap().getAttributeInstanceByName(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName()).applyModifier(attr);
}
catch (IllegalArgumentException ex) {}
}
}
示例10: onDeath
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDeath(PlayerEvent.Clone event) {
if (event.getEntityPlayer().getEntityWorld().isRemote) {
return;
}
PlayerCivilizationCapability newCap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
PlayerCivilizationCapability originalCap = PlayerCivilizationCapabilityImpl.get(event.getOriginal());
if (originalCap == null) {
return;
}
if (newCap == null) {
throw new NullPointerException("missing player capability during clone");
}
// System.out.println("CLONE: " + originalCap.writeNBT());
newCap.readNBT(originalCap.writeNBT());
}
示例11: onSave
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onSave(PlayerEvent.SaveToFile event) {
if (event.getEntityPlayer().getEntityWorld().isRemote) {
return;
}
PlayerCivilizationCapability cap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
if (cap == null) {
return;
}
NBTTagCompound civData = cap.writeNBT();
// System.out.println("SAVE: " + civData);
if (civData == null || civData.getTag("reputations") == null || ((NBTTagList) civData.getTag("reputations")).tagCount() < 1) {
// System.out.println("******************Not writing empty ToroQuest
// data for player " + event.getEntityPlayer().getName());
return;
}
event.getEntityPlayer().getEntityData().setTag(ToroQuest.MODID + ".playerCivilization", civData);
}
示例12: onLoad
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLoad(PlayerEvent.LoadFromFile event) {
if (event.getEntityPlayer().getEntityWorld().isRemote) {
return;
}
PlayerCivilizationCapability cap = PlayerCivilizationCapabilityImpl.get(event.getEntityPlayer());
if (cap == null) {
return;
}
NBTTagCompound c = event.getEntityPlayer().getEntityData().getCompoundTag(ToroQuest.MODID + ".playerCivilization");
if (c == null) {
// System.out.println("******************Missing civ data on load");
} else {
System.out.println("LOAD: " + c.toString());
}
cap.readNBT(c);
}
示例13: onClonePlayer
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
@SubscribeEvent
public void onClonePlayer(PlayerEvent.Clone event) {
if (event.isWasDeath()) {
final CapabilityMana.IMana manaOriginal = event.getOriginal().getCapability(CapabilityMana.MANA, null);
final CapabilityMana.IMana manaNew = event.getEntityPlayer().getCapability(CapabilityMana.MANA, null);
manaNew.setMana(manaOriginal.getMana());
manaNew.setMaxMana(manaOriginal.getMaxMana());
final CapabilityResearchPoints.IResearchPoints researchPointsOriginal = event.getOriginal().getCapability(CapabilityResearchPoints.RESEARCHPOINTS, null);
final CapabilityResearchPoints.IResearchPoints researchPointsNew = event.getEntityPlayer().getCapability(CapabilityResearchPoints.RESEARCHPOINTS, null);
researchPointsNew.setResearchPoints(researchPointsOriginal.getResearchPoints());
final CapabilityResearchActivites.IResearchActivities researchActivitesOriginal = event.getOriginal().getCapability(CapabilityResearchActivites.RESEARCHACTIVITIES, null);
final CapabilityResearchActivites.IResearchActivities researchActivitesNew = event.getEntityPlayer().getCapability(CapabilityResearchActivites.RESEARCHACTIVITIES, null);
researchActivitesNew.setMinedBlocks(researchActivitesOriginal.getMinedBlocks());
}
}
示例14: onClone
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
/**
* This occurs when a player dies and is used to make sure that a player does not get a duplicate starting house.
* @param event
*/
@SubscribeEvent
public static void onClone(PlayerEvent.Clone event)
{
if (event.getEntityPlayer() instanceof EntityPlayerMP)
{
// Don't add the tag unless the house item was added. This way it can be added if the feature is turned on.
// When the player is cloned, make sure to copy the tag. If this is not done the item can be given to the player again if they die before the log out and log back in.
NBTTagCompound originalTag = event.getOriginal().getEntityData();
// Use the server configuration to determine if the house should be added for this player.
if (Prefab.proxy.proxyConfiguration.addHouseItem)
{
if (originalTag.hasKey(EntityPlayerConfiguration.PLAYER_ENTITY_TAG))
{
NBTTagCompound newPlayerTag = event.getEntityPlayer().getEntityData();
newPlayerTag.setTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG, originalTag.getTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG));
// Send the persist tag to the client.
Prefab.network.sendTo(new PlayerEntityTagMessage(originalTag.getCompoundTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG)), (EntityPlayerMP)event.getEntityPlayer());
}
}
}
}
示例15: playerBreakSpeed
import net.minecraftforge.event.entity.player.PlayerEvent; //導入依賴的package包/類
/** Adjusts block breaking speed. */
@SubscribeEvent
public void playerBreakSpeed(PlayerEvent.BreakSpeed event) {
Block block = event.getState().getBlock();
ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();
String toolRequired = block.getHarvestTool(event.getState());
// Make axe and pickaxe blocks unbreakable without tool
if (("axe".equals(toolRequired) &&
!(stack.getItem() instanceof ItemAxe)) ||
("pickaxe".equals(toolRequired) &&
!(stack.getItem() instanceof ItemPickaxe))) {
event.setCanceled(true);
}
}