本文整理汇总了Java中net.minecraftforge.event.entity.EntityJoinWorldEvent.getWorld方法的典型用法代码示例。如果您正苦于以下问题:Java EntityJoinWorldEvent.getWorld方法的具体用法?Java EntityJoinWorldEvent.getWorld怎么用?Java EntityJoinWorldEvent.getWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.EntityJoinWorldEvent
的用法示例。
在下文中一共展示了EntityJoinWorldEvent.getWorld方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: playerJoin
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void playerJoin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityPlayer && !event.getWorld().isRemote) {
ExtendedPlayer ePlayer = ExtendedPlayerProvider.getExtendedPlayer((EntityPlayer) event.getEntity());
ExtendedPlayerInventory inventory = ePlayer.getInventory();
for (int a=0;a<inventory.getSlots();a++) inventory.setChanged(a,true);
for (EntityPlayer p : event.getEntity().getEntityWorld().playerEntities) {
if (p.getEntityId() != event.getEntity().getEntityId()) {
ExtendedPlayer ePlayer2 = ExtendedPlayerProvider.getExtendedPlayer(p);
ExtendedPlayerInventory inventory2 = ePlayer2.getInventory();
for (int a=0;a<inventory2.getSlots();a++) inventory2.setChanged(a,true);
}
}
String[] ia = new String[inventory.getSlots()];
Arrays.fill(ia, "");
syncCheck.put(event.getEntity().getCachedUniqueIdString(), ia);
}
}
示例3: redstoneHandler
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void redstoneHandler(EntityJoinWorldEvent event) {
if (event.getWorld().isRemote)
{
return;
}
if (event.getEntity() instanceof EntityItem && !(event.getEntity() instanceof EntityBurnableItem))
{
EntityItem item = (EntityItem) event.getEntity();
if (EntityBurnableItem.isBurnable(item.getItem()))
{
EntityBurnableItem newItem = new EntityBurnableItem(event.getWorld(), item.posX, item.posY, item.posZ, item.getItem());
newItem.motionX = item.motionX;
newItem.motionY = item.motionY;
newItem.motionZ = item.motionZ;
newItem.setDefaultPickupDelay();
item.setDead();
event.getWorld().spawnEntity(newItem);
}
}
}
示例4: 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);
}
}
示例5: 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;
}
}
}
}
示例6: 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());
}
}
}
示例7: onEntityJoinWorldEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) {
if (!e.getWorld().isRemote) {
List<TileEntity> loadedTileEntityList = e.getWorld().loadedTileEntityList;
for (int i = loadedTileEntityList.size() - 1; i >= 0; i--) {
TileEntity tileEntity = loadedTileEntityList.get(i);
if (tileEntity instanceof OfferingBoxTileEntity) {
if (((OfferingBoxTileEntity) tileEntity).getChargeLevel() > 0) {
if (TotemHelper.hasTotemType((OfferingBoxTileEntity) tileEntity, TotemType.COW)) {
Modifiers mods = TotemHelper.getModifiers(e.getWorld(), (OfferingBoxTileEntity) tileEntity);
int radius = TotemHelper.DEFAULT_RADIUS + (int) (TotemHelper.RANGE_BOOST * mods.range);
if (!canSpawnMobHere(tileEntity.getPos(), e.getEntity(), radius)) {
//FMLLog.log(Level.ERROR, "Stopped mob from spawning with radius: " + radius);
e.setCanceled(true);
break;
}
}
}
}
}
}
}
示例8: onEntityJoinWorldEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent e) {
if (!e.getWorld().isRemote) {
List<TileEntity> loadedTileEntityList = new ArrayList<>(e.getWorld().loadedTileEntityList);
for (TileEntity tileEntity : loadedTileEntityList) {
if (tileEntity instanceof OfferingBoxTileEntity) {
if (((OfferingBoxTileEntity) tileEntity).getChargeLevel() > 0) {
if (TotemHelper.hasTotemType((OfferingBoxTileEntity) tileEntity, TotemType.CREEPER)) {
Modifiers mods = TotemHelper.getModifiers(e.getWorld(), (OfferingBoxTileEntity) tileEntity);
int radius = TotemHelper.DEFAULT_RADIUS + (int) (TotemHelper.RANGE_BOOST * mods.range);
if (!canSpawnMobHere(tileEntity.getPos(), e.getEntity(), radius)) {
//FMLLog.log(Level.ERROR, "Stopped mob from spawning with radius: " + radius);
e.setCanceled(true);
break;
}
}
}
}
}
}
}
示例9: 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!"));
}
}
}
示例10: 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);
}
}
}
}
}
示例11: onEntityJoinedWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinedWorld(EntityJoinWorldEvent event)
{
if (!Config.getInstance().isSivIntegration())
return;
if (event.getWorld().isRemote && !hasJoinedWorld && Minecraft.getMinecraft().player != null)
{
hasJoinedWorld = true;
CreeperHost.instance.makeQueryGetter();
if (CreeperHost.instance.getQueryGetter() != null)
{
CreeperHost.instance.getQueryGetter().run();
}
}
}
示例12: entitySpawned
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void entitySpawned(EntityJoinWorldEvent event){
// This only runs server side
if(event.getWorld().isRemote)return;
if(EntityVillager.class.isInstance(event.getEntity())
&& !event.getEntity().getEntityData().getBoolean(tagName)){
if(ConfigHandler.LOGGING){
LogManager.getLogger().log(Level.INFO, "A villager spawned at x" + event.getEntity().posX + "z" + event.getEntity().posZ + " and has been added to the data list.");
}
// set this to true to inform future calls of this code that this villager has been handled.
event.getEntity().getEntityData().setBoolean(tagName, true);
// have to use the MathHelper workaround because chunkX and chunkZ are 0 on spawn
NBTDataHandler.incrementVillagersSpawnedForChunk(event.getWorld().provider.getDimension(), MathHelper.floor(event.getEntity().posX / 16.0D), MathHelper.floor(event.getEntity().posZ / 16.0D));
}
}
示例13: onItemSpawnEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemSpawnEvent(EntityJoinWorldEvent event)
{
if(event.getWorld().isRemote && event.getEntity() instanceof EntityItem)
{
Iterator<Map.Entry<String, ItemStack>> ite = playerTool.entrySet().iterator();
while(ite.hasNext())
{
Map.Entry<String, ItemStack> e = ite.next();
if(e.getValue().isItemEqual(((EntityItem)event.getEntity()).getItem()))
{
List<Entity> list = event.getWorld().getEntitiesInAABBexcluding(event.getEntity(), event.getEntity().getEntityBoundingBox(), Predicates.instanceOf(EntityPlayer.class));
boolean flag = false;
for(Entity ent : list)
{
if(ent.getName().equals(e.getKey()))
{
flag = true;
break;
}
}
if(flag)
{
ite.remove();
break;
}
}
}
}
}
示例14: onEntityJoinWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent e)
{
//Replace Minecart with Furnace with Minecart with Kiln
if(BBConfig.moduleFurnaces && e.getEntity().getClass() == EntityMinecartFurnace.class && ((EntityMinecartFurnace) e.getEntity()).getDisplayTile() == Blocks.FURNACE.getDefaultState())
{
if(!e.getWorld().isRemote)
{
e.getEntity().setDead();
EntityMinecartKiln kilnCart = new EntityMinecartKiln(e.getWorld(), e.getEntity().posX, e.getEntity().posY, e.getEntity().posZ);
e.getWorld().spawnEntity(kilnCart);
}
}
}
示例15: onJoinWorld
import net.minecraftforge.event.entity.EntityJoinWorldEvent; //导入方法依赖的package包/类
@SubscribeEvent()
public void onJoinWorld(EntityJoinWorldEvent event)
{
Entity entity = event.getEntity();
if(entity instanceof EntityPlayer)
{
if(event.getWorld() != null)
{
if(!event.getWorld().isRemote) //Server-side
{
CraftingParadiseSaveData.get(event.getWorld());
PlanetModule core = ActivePlanet.coreModule;
PlanetModule mantle = ActivePlanet.mantleModule;
PlanetModule crust = ActivePlanet.crustModule;
PlanetModule land = ActivePlanet.landscapeModule;
PlanetModule worldType = ActivePlanet.worldModule;
PlanetModule atmos = ActivePlanet.atmosphereModule;
int coreID = core == null ? -1 : core.moduleId;
int mantleID = mantle == null ? -1 : mantle.moduleId;
int crustID = crust == null ? -1 : crust.moduleId;
int landID = land == null ? -1 : land.moduleId;
int worldTypeID = worldType == null ? -1 : worldType.moduleId;
int atmosID = atmos == null ? -1 : atmos.moduleId;
PacketHandler.INSTANCE.sendTo(new MessageClientPlanetChange(coreID, mantleID, crustID, landID, worldTypeID, atmosID), (EntityPlayerMP) entity);
}
}
}
}