Some tweaks, some fixes, some removals of redundancies

This commit is contained in:
pahimar 2012-12-19 16:56:49 -05:00
parent a1e45baf45
commit 46d95ca362
7 changed files with 84 additions and 26 deletions

View file

@ -16,9 +16,11 @@ import com.pahimar.ee3.lib.ActionTypes;
import com.pahimar.ee3.lib.Particles; import com.pahimar.ee3.lib.Particles;
import com.pahimar.ee3.lib.Sounds; import com.pahimar.ee3.lib.Sounds;
import com.pahimar.ee3.network.PacketTypeHandler; import com.pahimar.ee3.network.PacketTypeHandler;
import com.pahimar.ee3.network.packet.PacketResultEvent;
import com.pahimar.ee3.network.packet.PacketSpawnParticle; import com.pahimar.ee3.network.packet.PacketSpawnParticle;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class WorldTransmutationHandler { public class WorldTransmutationHandler {
@ -97,7 +99,11 @@ public class WorldTransmutationHandler {
hasSoundPlayed = true; hasSoundPlayed = true;
thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.TRANSMUTE, 0.5F, 1.0F); thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.TRANSMUTE, 0.5F, 1.0F);
} }
if ((x == 0) && (y == 0) && (z == 0)) {
PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.populatePacket(new PacketResultEvent(true, false)), (Player)thePlayer);
}
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_SMOKE, originX + x + (xShift * xSign), originY + y + (yShift * ySign), originZ + z + (zShift * zSign), 0D * xSign, 0.05D * ySign, 0D * zSign))); PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_SMOKE, originX + x + (xShift * xSign), originY + y + (yShift * ySign), originZ + z + (zShift * zSign), 0D * xSign, 0.05D * ySign, 0D * zSign)));
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_EXPLODE, originX + x + (xShift * xSign), originY + y + (yShift * ySign), originZ + z + (zShift * zSign), 0D * xSign, 0.15D * ySign, 0D * zSign))); PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_EXPLODE, originX + x + (xShift * xSign), originY + y + (yShift * ySign), originZ + z + (zShift * zSign), 0D * xSign, 0.15D * ySign, 0D * zSign)));
} }

View file

@ -100,7 +100,9 @@ public class ItemMiniumStone extends ItemEE
openPortableCrafting(thePlayer); openPortableCrafting(thePlayer);
} }
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) { else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true); if (TransmutationHelper.targetBlockStack != null) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true);
}
} }
} }

View file

@ -179,16 +179,28 @@ public class ItemPhilosopherStone extends ItemEE
openPortableCrafting(thePlayer); openPortableCrafting(thePlayer);
} }
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) { else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true); if (TransmutationHelper.targetBlockStack != null) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true);
}
} }
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_CHARGE)) { else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_CHARGE)) {
if (!thePlayer.isSneaking()) { if (!thePlayer.isSneaking()) {
increaseCharge(itemStack); if (getCharge(itemStack) == maxChargeLevel) {
thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel))); thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_FAIL, 0.5F, 0.5F + (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel)));
}
else {
increaseCharge(itemStack);
thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel)));
}
} }
else { else {
decreaseCharge(itemStack); if (getCharge(itemStack) == 0) {
thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel)))); thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_FAIL, 0.5F, 0.5F + (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel)));
}
else {
decreaseCharge(itemStack);
thePlayer.worldObj.playSoundAtEntity(thePlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - (0.5F * (getCharge(itemStack) * 1.0F / maxChargeLevel))));
}
} }
} }

View file

@ -1,18 +0,0 @@
package com.pahimar.ee3.lib;
/**
* PacketIds
*
* Library containing the various ids for different packets in the mod
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class PacketIds {
public static final int KEYBINDING_PRESSED = 0;
public static final int TILEENTITY_UPDATE = 1;
public static final int WORLD_TRANSMUTATION_EVENT = 2;
}

View file

@ -44,5 +44,7 @@ public class Sounds {
public static final String WALL = SOUND_PREFIX + "wall"; public static final String WALL = SOUND_PREFIX + "wall";
public static final String WATER_BALL = SOUND_PREFIX + "waterball"; public static final String WATER_BALL = SOUND_PREFIX + "waterball";
public static final String WIND = SOUND_PREFIX + "wind"; public static final String WIND = SOUND_PREFIX + "wind";
public static final String CHARGE_FAIL = "mob.enderdragon.hit";
} }

View file

@ -10,6 +10,7 @@ import com.pahimar.ee3.lib.Reference;
import com.pahimar.ee3.network.packet.PacketEE; import com.pahimar.ee3.network.packet.PacketEE;
import com.pahimar.ee3.network.packet.PacketKeyPressed; import com.pahimar.ee3.network.packet.PacketKeyPressed;
import com.pahimar.ee3.network.packet.PacketRequestEvent; 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.PacketSpawnParticle;
import com.pahimar.ee3.network.packet.PacketTileUpdate; import com.pahimar.ee3.network.packet.PacketTileUpdate;
@ -27,7 +28,8 @@ public enum PacketTypeHandler {
KEY(PacketKeyPressed.class), KEY(PacketKeyPressed.class),
TILE(PacketTileUpdate.class), TILE(PacketTileUpdate.class),
REQUEST_EVENT(PacketRequestEvent.class), REQUEST_EVENT(PacketRequestEvent.class),
SPAWN_PARTICLE(PacketSpawnParticle.class); SPAWN_PARTICLE(PacketSpawnParticle.class),
RESULT_EVENT(PacketResultEvent.class);
private Class<? extends PacketEE> clazz; private Class<? extends PacketEE> clazz;

View file

@ -0,0 +1,52 @@
package com.pahimar.ee3.network.packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
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(), true);
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());
}
}
}