Fixed a big bug that prevented in world transmutation working in SMP environments (sorry guys), and fixed the ability to cycle through transmutation options while in SMP (half-assed, will revisit)
This commit is contained in:
parent
ea431cb3e7
commit
db2891c508
11 changed files with 103 additions and 124 deletions
|
@ -8,7 +8,7 @@ public class ActionRequestHandler {
|
|||
|
||||
@ForgeSubscribe
|
||||
public void onModActionEvent(ActionRequestEvent event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,13 +53,17 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
|
|||
|
||||
if (currentItem != null) {
|
||||
if (currentItem.getItem() instanceof IKeyBound) {
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(kb.keyDescription)));
|
||||
if (!KeyBindingHelper.isClientSided(kb.keyDescription)) {
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(kb.keyDescription)));
|
||||
}
|
||||
else {
|
||||
((IKeyBound) currentItem.getItem()).doKeyBindingAction(player, currentItem, kb.keyDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.pahimar.ee3.core.helper;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
/**
|
||||
|
@ -51,4 +53,14 @@ public class KeyBindingHelper {
|
|||
|
||||
return isRepeating;
|
||||
}
|
||||
|
||||
// TODO Still not ideal, won't work for every case. Specifically, make it context sensitive
|
||||
public static boolean isClientSided(String keybinding) {
|
||||
if (keybinding.equalsIgnoreCase(ConfigurationSettings.KEYBINDING_TOGGLE)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ public class TransmutationHelper {
|
|||
if (list != null) {
|
||||
return getNextBlock(id, meta, id, meta);
|
||||
}
|
||||
|
||||
return nextStack;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package com.pahimar.ee3.core.proxy;
|
||||
|
||||
import static com.pahimar.ee3.lib.CustomItemRarity.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.EnumHelperClient;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.client.audio.SoundHandler;
|
||||
import com.pahimar.ee3.client.renderer.ItemCalcinatorRenderer;
|
||||
import com.pahimar.ee3.client.renderer.texturefx.TextureRedWaterFX;
|
||||
|
@ -15,6 +20,9 @@ import com.pahimar.ee3.core.handlers.DrawBlockHighlightHandler;
|
|||
import com.pahimar.ee3.core.handlers.KeyBindingHandler;
|
||||
import com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler;
|
||||
import com.pahimar.ee3.core.helper.KeyBindingHelper;
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.item.IChargeable;
|
||||
import com.pahimar.ee3.lib.ActionTypes;
|
||||
import com.pahimar.ee3.lib.BlockIds;
|
||||
import com.pahimar.ee3.lib.RenderIds;
|
||||
import com.pahimar.ee3.lib.Sprites;
|
||||
|
@ -117,9 +125,66 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketRequestEvent(eventType, originX, originY, originZ, sideHit, rangeX, rangeY, rangeZ, data)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
|
||||
if (TransmutationHelper.targetBlockStack != null) {
|
||||
if (itemStack != null) {
|
||||
int pnX = 1;
|
||||
int pnY = 1;
|
||||
int pnZ = 1;
|
||||
if (itemStack.getItem() instanceof IChargeable) {
|
||||
int charge = ((IChargeable) itemStack.getItem()).getCharge(itemStack) * 2;
|
||||
switch (ForgeDirection.getOrientation(sideHit)) {
|
||||
case UP: {
|
||||
pnX = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
pnX = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
pnX = 1 + charge;
|
||||
pnY = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
pnX = 1 + charge;
|
||||
pnY = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
pnY = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
pnY = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
pnX = 0;
|
||||
pnY = 0;
|
||||
pnZ = 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EquivalentExchange3.proxy.sendRequestEventPacket(ActionTypes.TRANSMUTATION, x, y, z, (byte) sideHit, (byte) pnX, (byte) pnY, (byte) pnZ, TransmutationHelper.formatTargetBlockInfo(TransmutationHelper.targetBlockStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.pahimar.ee3.core.proxy;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiCalcinator;
|
||||
|
@ -65,7 +66,11 @@ public class CommonProxy implements IGuiHandler {
|
|||
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||
}
|
||||
|
||||
public void sendWorldEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
|
||||
}
|
||||
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ public interface ITransmutationStone {
|
|||
|
||||
public abstract void openPortableCrafting(EntityPlayer thePlayer);
|
||||
|
||||
public abstract void transmuteBlocks(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit);
|
||||
public abstract void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemMiniumStone extends ItemEE
|
||||
implements ITransmutationStone, IKeyBound {
|
||||
public class ItemMiniumStone extends ItemEE implements ITransmutationStone,
|
||||
IKeyBound {
|
||||
|
||||
public ItemMiniumStone(int id) {
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class ItemMiniumStone extends ItemEE
|
|||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) {
|
||||
|
||||
transmuteBlocks(itemStack, entityPlayer, world, x, y, z, sideHit);
|
||||
transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -84,13 +84,9 @@ public class ItemMiniumStone extends ItemEE
|
|||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlocks(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (TransmutationHelper.targetBlockStack != null) {
|
||||
EquivalentExchange3.proxy.sendWorldEventPacket(ActionTypes.TRANSMUTATION, x, y, z, (byte) sideHit, (byte) 0, (byte) 0, (byte) 0, TransmutationHelper.formatTargetBlockInfo(TransmutationHelper.targetBlockStack));
|
||||
}
|
||||
}
|
||||
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, sideHit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,8 +28,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemPhilosopherStone extends ItemEE
|
||||
implements ITransmutationStone, IChargeable, IKeyBound {
|
||||
public class ItemPhilosopherStone extends ItemEE implements
|
||||
ITransmutationStone, IChargeable, IKeyBound {
|
||||
|
||||
private int maxChargeLevel;
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class ItemPhilosopherStone extends ItemEE
|
|||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) {
|
||||
|
||||
transmuteBlocks(itemStack, entityPlayer, world, x, y, z, sideHit);
|
||||
transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,57 +89,9 @@ public class ItemPhilosopherStone extends ItemEE
|
|||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlocks(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (TransmutationHelper.targetBlockStack != null) {
|
||||
int pnX = 1;
|
||||
int pnY = 1;
|
||||
int pnZ = 1;
|
||||
switch (ForgeDirection.getOrientation(sideHit)) {
|
||||
case UP: {
|
||||
pnX = 1 + getCharge(itemStack) * 2;
|
||||
pnZ = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
pnX = 1 + getCharge(itemStack) * 2;
|
||||
pnZ = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
pnX = 1 + getCharge(itemStack) * 2;
|
||||
pnY = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
pnX = 1 + getCharge(itemStack) * 2;
|
||||
pnY = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
pnY = 1 + getCharge(itemStack) * 2;
|
||||
pnZ = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
pnY = 1 + getCharge(itemStack) * 2;
|
||||
pnZ = 1 + getCharge(itemStack) * 2;
|
||||
break;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
pnX = 0;
|
||||
pnY = 0;
|
||||
pnZ = 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
EquivalentExchange3.proxy.sendWorldEventPacket(ActionTypes.TRANSMUTATION, x, y, z, (byte) sideHit, (byte) pnX, (byte) pnY, (byte) pnZ, TransmutationHelper.formatTargetBlockInfo(TransmutationHelper.targetBlockStack));
|
||||
}
|
||||
}
|
||||
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, sideHit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.pahimar.ee3.lib.Reference;
|
|||
import com.pahimar.ee3.network.packet.PacketEE;
|
||||
import com.pahimar.ee3.network.packet.PacketKeyPressed;
|
||||
import com.pahimar.ee3.network.packet.PacketRequestEvent;
|
||||
import com.pahimar.ee3.network.packet.PacketResultEvent;
|
||||
import com.pahimar.ee3.network.packet.PacketSpawnParticle;
|
||||
import com.pahimar.ee3.network.packet.PacketTileUpdate;
|
||||
|
||||
|
@ -28,8 +27,7 @@ public enum PacketTypeHandler {
|
|||
KEY(PacketKeyPressed.class),
|
||||
TILE(PacketTileUpdate.class),
|
||||
REQUEST_EVENT(PacketRequestEvent.class),
|
||||
SPAWN_PARTICLE(PacketSpawnParticle.class),
|
||||
RESULT_EVENT(PacketResultEvent.class);
|
||||
SPAWN_PARTICLE(PacketSpawnParticle.class);
|
||||
|
||||
private Class<? extends PacketEE> clazz;
|
||||
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package com.pahimar.ee3.network.packet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
||||
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class PacketResultEvent extends PacketEE {
|
||||
|
||||
public boolean shouldChangeNextBlock;
|
||||
public boolean shouldDestroyCurrentlyHeldItem;
|
||||
|
||||
public PacketResultEvent() {
|
||||
|
||||
super(PacketTypeHandler.RESULT_EVENT, false);
|
||||
}
|
||||
|
||||
public PacketResultEvent(boolean shouldChangeNextBlock, boolean shouldDestroyCurrentlyHeldItem) {
|
||||
|
||||
super(PacketTypeHandler.RESULT_EVENT, false);
|
||||
this.shouldChangeNextBlock = shouldChangeNextBlock;
|
||||
this.shouldDestroyCurrentlyHeldItem = shouldDestroyCurrentlyHeldItem;
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
|
||||
data.writeBoolean(shouldChangeNextBlock);
|
||||
data.writeBoolean(shouldDestroyCurrentlyHeldItem);
|
||||
}
|
||||
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
|
||||
this.shouldChangeNextBlock = data.readBoolean();
|
||||
this.shouldDestroyCurrentlyHeldItem = data.readBoolean();
|
||||
}
|
||||
|
||||
public void execute(INetworkManager manager, Player player) {
|
||||
|
||||
System.out.println(shouldChangeNextBlock);
|
||||
if (shouldChangeNextBlock) {
|
||||
System.out.format("previous %d:%d, current %d:%d, target %d:%d\n", TransmutationHelper.previousBlockStack.itemID, TransmutationHelper.previousBlockStack.getItemDamage(), TransmutationHelper.currentBlockStack.itemID, TransmutationHelper.currentBlockStack.getItemDamage(), TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
|
||||
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
|
||||
System.out.format("previous %d:%d, current %d:%d, target %d:%d\n", TransmutationHelper.previousBlockStack.itemID, TransmutationHelper.previousBlockStack.getItemDamage(), TransmutationHelper.currentBlockStack.itemID, TransmutationHelper.currentBlockStack.getItemDamage(), TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue