-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from fixrtm/kaiz-patch-1.2
port Kaiz patch 1.2
- Loading branch information
Showing
24 changed files
with
699 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.anatawa12.fixRtm | ||
|
||
import org.lwjgl.input.Keyboard | ||
|
||
object KeyboardUtil { | ||
fun isIntegerKey(par: Int): Boolean { | ||
return when (par) { | ||
Keyboard.KEY_1, | ||
Keyboard.KEY_2, | ||
Keyboard.KEY_3, | ||
Keyboard.KEY_4, | ||
Keyboard.KEY_5, | ||
Keyboard.KEY_6, | ||
Keyboard.KEY_7, | ||
Keyboard.KEY_8, | ||
Keyboard.KEY_9, | ||
Keyboard.KEY_0, | ||
|
||
Keyboard.KEY_NUMPAD1, | ||
Keyboard.KEY_NUMPAD2, | ||
Keyboard.KEY_NUMPAD3, | ||
Keyboard.KEY_NUMPAD4, | ||
Keyboard.KEY_NUMPAD5, | ||
Keyboard.KEY_NUMPAD6, | ||
Keyboard.KEY_NUMPAD7, | ||
Keyboard.KEY_NUMPAD8, | ||
Keyboard.KEY_NUMPAD9, | ||
Keyboard.KEY_NUMPAD0, | ||
|
||
Keyboard.KEY_UP, | ||
Keyboard.KEY_PRIOR, | ||
Keyboard.KEY_LEFT, | ||
Keyboard.KEY_RIGHT, | ||
|
||
Keyboard.KEY_MINUS, | ||
Keyboard.KEY_SUBTRACT, | ||
Keyboard.KEY_BACK, | ||
Keyboard.KEY_DELETE, | ||
-> true | ||
else -> false | ||
} | ||
} | ||
|
||
fun isDecimalNumberKey(par: Int): Boolean { | ||
return isIntegerKey(par) || par == Keyboard.KEY_PERIOD || par == Keyboard.KEY_DECIMAL | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.anatawa12.fixRtm.gui | ||
|
||
import com.anatawa12.fixRtm.KeyboardUtil | ||
import jp.ngt.ngtlib.block.TileEntityPlaceable | ||
import jp.ngt.ngtlib.gui.GuiScreenCustom | ||
import jp.ngt.ngtlib.gui.GuiTextFieldCustom | ||
import jp.ngt.ngtlib.network.PacketNBT | ||
import net.minecraft.client.gui.GuiButton | ||
import net.minecraft.client.resources.I18n | ||
import org.lwjgl.input.Keyboard | ||
|
||
class GuiChangeOffset(private var tileEntity: TileEntityPlaceable) : GuiScreenCustom() { | ||
private lateinit var fieldOffsetX: GuiTextFieldCustom | ||
private lateinit var fieldOffsetY: GuiTextFieldCustom | ||
private lateinit var fieldOffsetZ: GuiTextFieldCustom | ||
private lateinit var fieldRotationYaw: GuiTextFieldCustom | ||
|
||
override fun initGui() { | ||
super.initGui() | ||
buttonList.clear() | ||
buttonList.add(GuiButton(0, width / 2 - 105, height - 28, 100, 20, I18n.format("gui.done"))) | ||
buttonList.add(GuiButton(1, width / 2 + 5, height - 28, 100, 20, I18n.format("gui.cancel"))) | ||
fieldOffsetX = setTextField(width - 70, 20, 60, 20, tileEntity.offsetX.toString()) | ||
fieldOffsetY = setTextField(width - 70, 50, 60, 20, tileEntity.offsetY.toString()) | ||
fieldOffsetZ = setTextField(width - 70, 80, 60, 20, tileEntity.offsetZ.toString()) | ||
fieldRotationYaw = setTextField(width - 70, 110, 60, 20, tileEntity.rotation.toString()) | ||
} | ||
|
||
override fun drawScreen(par1: Int, par2: Int, par3: Float) { | ||
drawDefaultBackground() | ||
super.drawScreen(par1, par2, par3) | ||
drawCenteredString(this.fontRenderer, "Offset X", width - 70, 10, 0xFFFFFF) | ||
drawCenteredString(this.fontRenderer, "Offset Y", width - 70, 40, 0xFFFFFF) | ||
drawCenteredString(this.fontRenderer, "Offset Z", width - 70, 70, 0xFFFFFF) | ||
drawCenteredString(this.fontRenderer, "Rotation Yaw", width - 70, 100, 0xFFFFFF) | ||
} | ||
|
||
override fun actionPerformed(button: GuiButton) { | ||
if (button.id == 0) { | ||
mc.displayGuiScreen(null) | ||
sendPacket() | ||
} else if (button.id == 1) { | ||
mc.displayGuiScreen(null) | ||
} | ||
super.actionPerformed(button) | ||
} | ||
|
||
override fun keyTyped(par1: Char, par2: Int) { | ||
if (par2 == Keyboard.KEY_ESCAPE || par2 == mc.gameSettings.keyBindInventory.keyCode) { | ||
mc.player.closeScreen() | ||
} | ||
if (currentTextField != null) { | ||
if (KeyboardUtil.isDecimalNumberKey(par2)) { | ||
currentTextField.textboxKeyTyped(par1, par2) | ||
} | ||
} | ||
} | ||
|
||
private fun updateValues() { | ||
val offsetX: Float = fieldOffsetX.text.toFloatOrNull() ?: tileEntity.offsetX | ||
val offsetY: Float = fieldOffsetY.text.toFloatOrNull() ?: tileEntity.offsetY | ||
val offsetZ: Float = fieldOffsetZ.text.toFloatOrNull() ?: tileEntity.offsetZ | ||
val rotation: Float = fieldRotationYaw.text.toFloatOrNull() ?: tileEntity.rotation | ||
tileEntity.setOffset(offsetX, offsetY, offsetZ, false) | ||
tileEntity.setRotation(rotation, false) | ||
} | ||
|
||
private fun sendPacket() { | ||
updateValues() | ||
PacketNBT.sendToServer(tileEntity) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.anatawa12.fixRtm.gui | ||
|
||
import com.anatawa12.fixRtm.gui.GuiId.ChangeOffset | ||
import com.anatawa12.fixRtm.gui.GuiId.values | ||
import jp.ngt.ngtlib.block.TileEntityPlaceable | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.world.World | ||
import net.minecraftforge.fml.common.network.IGuiHandler | ||
|
||
class GuiHandler : IGuiHandler { | ||
override fun getServerGuiElement(ID: Int, player: EntityPlayer?, world: World?, x: Int, y: Int, z: Int): Any? { | ||
return when (values()[ID]) { | ||
ChangeOffset -> null | ||
} | ||
} | ||
|
||
override fun getClientGuiElement(ID: Int, player: EntityPlayer?, world: World?, x: Int, y: Int, z: Int): Any? { | ||
return when (values()[ID]) { | ||
ChangeOffset -> GuiChangeOffset(world!!.getTileEntity(BlockPos(x, y, z)) as TileEntityPlaceable) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.anatawa12.fixRtm.gui | ||
|
||
enum class GuiId { | ||
ChangeOffset, | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/ngtlib-patches/jp/ngt/ngtlib/block/TileEntityPlaceable.java.pm.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- a/jp/ngt/ngtlib/block/TileEntityPlaceable.java | ||
+++ b/jp/ngt/ngtlib/block/TileEntityPlaceable.java | ||
@@ -4,10 +4,11 @@ | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
|
||
public abstract class TileEntityPlaceable extends TileEntityCustom { | ||
private float rotation; | ||
+ private float offsetX, offsetY, offsetZ; | ||
|
||
public void readFromNBT(NBTTagCompound nbt) { | ||
super.readFromNBT(nbt); | ||
this.setRotation(nbt.getFloat("Yaw"), false); | ||
} | ||
@@ -33,6 +34,28 @@ | ||
|
||
public void setRotation(EntityPlayer player, float rotationInterval, boolean synch) { | ||
int i = NGTMath.floor(NGTMath.normalizeAngle((double)(-player.rotationYaw) + 180.0D + (double)rotationInterval / 2.0D) / (double)rotationInterval); | ||
this.setRotation((float)i * rotationInterval, synch); | ||
} | ||
+ | ||
+ public float getOffsetX() { | ||
+ return offsetX; | ||
+ } | ||
+ | ||
+ public float getOffsetY() { | ||
+ return offsetY; | ||
+ } | ||
+ | ||
+ public float getOffsetZ() { | ||
+ return offsetZ; | ||
+ } | ||
+ | ||
+ public void setOffset(float offsetX, float offsetY, float offsetZ, boolean sync) { | ||
+ this.offsetX = offsetX; | ||
+ this.offsetY = offsetY; | ||
+ this.offsetZ = offsetZ; | ||
+ if (sync) { | ||
+ this.getUpdatePacket(); | ||
+ this.markDirty(); | ||
+ } | ||
+ } | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/rtm-patches/jp/ngt/rtm/block/BlockMachineBase.java.pm.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- a/jp/ngt/rtm/block/BlockMachineBase.java | ||
+++ b/jp/ngt/rtm/block/BlockMachineBase.java | ||
@@ -22,10 +22,26 @@ | ||
this.clickMachine(holder.getWorld(), holder.getBlockPos().getX(), holder.getBlockPos().getY(), holder.getBlockPos().getZ(), holder.getPlayer()); | ||
return true; | ||
} | ||
|
||
protected boolean clickMachine(World world, int x, int y, int z, EntityPlayer player) { | ||
+ if (world.isRemote) { | ||
+ if (jp.ngt.ngtlib.util.NGTUtil.isEquippedItem(player, jp.ngt.rtm.RTMItem.installedObject)) { | ||
+ net.minecraft.item.ItemStack itemStack = player.inventory.getCurrentItem(); | ||
+ TileEntityMachineBase machine = (TileEntityMachineBase) world.getTileEntity(new BlockPos(x, y, z)); | ||
+ assert machine != null; | ||
+ if (com.anatawa12.fixRtm.UtilsKt.isItemOf(itemStack, machine)) { | ||
+ com.anatawa12.fixRtm.UtilsKt.openGui(player, com.anatawa12.fixRtm.gui.GuiId.ChangeOffset, player.world, x, y, z); | ||
+ return true; | ||
+ } | ||
+ } | ||
+ | ||
+ if (player.isSneaking()) { | ||
+ player.openGui(RTMCore.instance, RTMCore.guiIdSelectTileEntityModel, player.world, x, y, z); | ||
+ return true; | ||
+ } | ||
+ } | ||
if (player.isSneaking()) { | ||
if (world.isRemote) { | ||
player.openGui(RTMCore.instance, RTMCore.guiIdSelectTileEntityModel, player.getEntityWorld(), x, y, z); | ||
} | ||
|
||
@@ -33,12 +49,15 @@ | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
+ @Deprecated | ||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { | ||
- TileEntityMachineBase tileentitymachinebase = (TileEntityMachineBase)world.getTileEntity(pos); | ||
+ net.minecraft.tileentity.TileEntity tile = world.getTileEntity(pos); | ||
+ if (!(tile instanceof TileEntityMachineBase)) return super.getLightValue(state); | ||
+ TileEntityMachineBase tileentitymachinebase = (TileEntityMachineBase)tile; | ||
if (tileentitymachinebase == null) { | ||
return 0; | ||
} else { | ||
MachineConfig machineconfig = (MachineConfig)((ModelSetMachine)tileentitymachinebase.getResourceState().getResourceSet()).getConfig(); | ||
return tileentitymachinebase.isGettingPower ? machineconfig.brightness[1] : machineconfig.brightness[0]; |
14 changes: 14 additions & 0 deletions
14
src/main/rtm-patches/jp/ngt/rtm/block/tileentity/RenderMachine.java.pm.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- a/jp/ngt/rtm/block/tileentity/RenderMachine.java | ||
+++ b/jp/ngt/rtm/block/tileentity/RenderMachine.java | ||
@@ -15,10 +15,11 @@ | ||
private void renderMachine(TileEntityMachineBase par1, double par2, double par4, double par6, float par8) { | ||
GL11.glPushMatrix(); | ||
GL11.glEnable(32826); | ||
GL11.glTranslatef((float)par2 + 0.5F, (float)par4, (float)par6 + 0.5F); | ||
GL11.glTranslatef(0.0F, 0.5F, 0.0F); | ||
+ GL11.glTranslatef(par1.getOffsetX(), par1.getOffsetY(), par1.getOffsetZ()); | ||
ModelSetMachine modelsetmachine = (ModelSetMachine)par1.getResourceState().getResourceSet(); | ||
MachineConfig machineconfig = (MachineConfig)modelsetmachine.getConfig(); | ||
if (machineconfig.rotateByMetadata) { | ||
switch(par1.getBlockMetadata()) { | ||
case 0: |
19 changes: 19 additions & 0 deletions
19
src/main/rtm-patches/jp/ngt/rtm/block/tileentity/TileEntityCrossingGate.java.pm.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- a/jp/ngt/rtm/block/tileentity/TileEntityCrossingGate.java | ||
+++ b/jp/ngt/rtm/block/tileentity/TileEntityCrossingGate.java | ||
@@ -66,13 +66,14 @@ | ||
|
||
@SideOnly(Side.CLIENT) | ||
public AxisAlignedBB getRenderBoundingBox() { | ||
float[] afloat = ((MachineConfig)((ModelSetMachine)this.getResourceState().getResourceSet()).getConfig()).renderAABB; | ||
BlockPos blockpos = this.getPos(); | ||
- AxisAlignedBB axisalignedbb = new AxisAlignedBB((double)((float)blockpos.getX() + afloat[0]), (double)((float)blockpos.getY() + afloat[1]), (double)((float)blockpos.getZ() + afloat[2]), (double)((float)blockpos.getX() + afloat[3]), (double)((float)blockpos.getY() + afloat[4]), (double)((float)blockpos.getZ() + afloat[5])); | ||
+ AxisAlignedBB axisalignedbb = new AxisAlignedBB((double)((float)blockpos.getX() + afloat[0]), (double)((float)blockpos.getY() + afloat[1]), (double)((float)blockpos.getZ() + afloat[2]), (double)((float)blockpos.getX() + afloat[3]), (double)((float)blockpos.getY() + afloat[4]), (double)((float)blockpos.getZ() + afloat[5])) | ||
+ .offset(getOffsetX(), getOffsetY(), getOffsetZ()); | ||
return axisalignedbb; | ||
} | ||
|
||
- protected ResourceType getSubType() { | ||
+ public ResourceType getSubType() { | ||
return RTMResource.MACHINE_GATE; | ||
} | ||
} |
Oops, something went wrong.