mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-26 23:13:07 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
f02b6bae19
commit
6b18eca613
89 files changed
+8520
-7190
No files matched your search
@@ -11,47 +11,46 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
|
||||
|
||||
/**
|
||||
* A class that maintains a map server<->client of which players are holding the control (or placement modifier key) much like sneaking.
|
||||
*/
|
||||
object ControlKeyModifer
|
||||
{
|
||||
implicit def playerControlValue(p:EntityPlayer) = new ControlKeyValue(p)
|
||||
|
||||
class ControlKeyValue(p:EntityPlayer)
|
||||
{
|
||||
def isControlDown = map(p)
|
||||
}
|
||||
|
||||
val map = HashMap[EntityPlayer, Boolean]().withDefaultValue(false)
|
||||
|
||||
/**
|
||||
* Implicit static for Java users.
|
||||
*/
|
||||
def isControlDown(p:EntityPlayer) = p.isControlDown
|
||||
/** A class that maintains a map server<->client of which players are holding
|
||||
* the control (or placement modifier key) much like sneaking.
|
||||
*/
|
||||
object ControlKeyModifer {
|
||||
implicit def playerControlValue(p: EntityPlayer) = new ControlKeyValue(p)
|
||||
|
||||
class ControlKeyValue(p: EntityPlayer) {
|
||||
def isControlDown = map(p)
|
||||
}
|
||||
|
||||
val map = HashMap[EntityPlayer, Boolean]().withDefaultValue(false)
|
||||
|
||||
/** Implicit static for Java users.
|
||||
*/
|
||||
def isControlDown(p: EntityPlayer) = p.isControlDown
|
||||
}
|
||||
|
||||
/**
|
||||
* Key Handler implementation
|
||||
*/
|
||||
object ControlKeyHandler extends KeyBinding("key.control", Keyboard.KEY_LCONTROL, "key.categories.gameplay")
|
||||
{
|
||||
import ControlKeyModifer._
|
||||
var wasPressed = false
|
||||
/** Key Handler implementation
|
||||
*/
|
||||
object ControlKeyHandler
|
||||
extends KeyBinding(
|
||||
"key.control",
|
||||
Keyboard.KEY_LCONTROL,
|
||||
"key.categories.gameplay"
|
||||
) {
|
||||
import ControlKeyModifer._
|
||||
var wasPressed = false
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
def tick(event:ClientTickEvent) {
|
||||
val pressed = getIsKeyPressed
|
||||
if(pressed != wasPressed) {
|
||||
wasPressed = pressed
|
||||
if(Minecraft.getMinecraft.getNetHandler != null)
|
||||
{
|
||||
map.put(Minecraft.getMinecraft.thePlayer, pressed)
|
||||
val packet = new PacketCustom(MultipartCPH.channel, 1)
|
||||
packet.writeBoolean(pressed)
|
||||
packet.sendToServer()
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
def tick(event: ClientTickEvent) {
|
||||
val pressed = getIsKeyPressed
|
||||
if (pressed != wasPressed) {
|
||||
wasPressed = pressed
|
||||
if (Minecraft.getMinecraft.getNetHandler != null) {
|
||||
map.put(Minecraft.getMinecraft.thePlayer, pressed)
|
||||
val packet = new PacketCustom(MultipartCPH.channel, 1)
|
||||
packet.writeBoolean(pressed)
|
||||
packet.sendToServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user