mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
Conflicts: src/main/scala/li/cil/oc/common/EventHandler.scala
This commit is contained in:
commit
aa2d7e8b11
@ -1069,6 +1069,11 @@ opencomputers {
|
||||
# avoid issues with computers timing out, but can also lead to higher
|
||||
# server load. AGAIN, USE WITH CARE!
|
||||
threadPriority: -1
|
||||
|
||||
# Whether to give a new player a free copy of the manual. This will only
|
||||
# happen one time per game, not per world, not per death. Once. If this
|
||||
# is still too much for your taste, disable it here ;-)
|
||||
giveManualToNewPlayers: true
|
||||
}
|
||||
|
||||
# Settings for mod integration (the mod previously known as OpenComponents).
|
||||
|
@ -294,6 +294,7 @@ class Settings(val config: Config) {
|
||||
val presentChance = config.getDouble("misc.presentChance") max 0 min 1
|
||||
val assemblerBlacklist = config.getStringList("misc.assemblerBlacklist")
|
||||
val threadPriority = config.getInt("misc.threadPriority")
|
||||
val giveManualToNewPlayers = config.getBoolean("misc.giveManualToNewPlayers")
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// printer
|
||||
|
@ -20,11 +20,14 @@ import li.cil.oc.server.machine.Machine
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
||||
import li.cil.oc.util._
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.util.FakePlayer
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent
|
||||
import net.minecraftforge.event.world.BlockEvent
|
||||
import net.minecraftforge.event.world.WorldEvent
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
@ -187,6 +190,23 @@ object EventHandler {
|
||||
keyboards.foreach(_.releasePressedKeys(e.player))
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def onEntityJoinWorld(e: EntityJoinWorldEvent): Unit = {
|
||||
if (Settings.get.giveManualToNewPlayers && !e.world.isRemote) e.entity match {
|
||||
case player: EntityPlayer if !player.isInstanceOf[FakePlayer] =>
|
||||
val nbt = player.getEntityData
|
||||
if (!nbt.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) {
|
||||
nbt.setTag(EntityPlayer.PERSISTED_NBT_TAG, new NBTTagCompound())
|
||||
}
|
||||
val ocData = nbt.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG)
|
||||
if (!ocData.getBoolean(Settings.namespace + "receivedManual")) {
|
||||
ocData.setBoolean(Settings.namespace + "receivedManual", true)
|
||||
player.inventory.addItemStackToInventory(api.Items.get(Constants.ItemName.Manual).createItemStack(1))
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
|
||||
lazy val drone = api.Items.get(Constants.ItemName.Drone)
|
||||
lazy val eeprom = api.Items.get(Constants.ItemName.EEPROM)
|
||||
lazy val mcu = api.Items.get(Constants.BlockName.Microcontroller)
|
||||
|
Loading…
x
Reference in New Issue
Block a user