This commit is contained in:
André Carvalho 2012-11-27 19:54:32 +00:00
commit 056576d4f8
19 changed files with 215 additions and 44 deletions

View file

@ -8,7 +8,9 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import ee3.client.core.handlers.DrawBlockHighlightHandler;
import ee3.client.core.handlers.KeyBindingHandler;
import ee3.client.core.handlers.SoundHandler;
@ -18,6 +20,7 @@ import ee3.client.render.RenderItemCalcinator;
import ee3.client.render.TextureRedWaterFX;
import ee3.client.render.TextureRedWaterFlowFX;
import ee3.common.core.CommonProxy;
import ee3.common.core.handlers.RenderTickHandler;
import ee3.common.lib.BlockIds;
import ee3.common.lib.Reference;
import ee3.common.lib.RenderIds;
@ -37,27 +40,38 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerKeyBindingHandler() {
KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler());
}
@Override
public void registerRenderTickHandler() {
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
}
@Override
public void registerDrawBlockHighlightHandler() {
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightHandler());
}
@Override
public void setKeyBinding(String name, int value) {
KeyBindingHelper.addKeyBinding(name, value);
KeyBindingHelper.addIsRepeating(false);
}
@Override
public void registerSoundHandler() {
MinecraftForge.EVENT_BUS.register(new SoundHandler());
}
@Override
public void initCustomRarityTypes() {
EnumHelperClient.addRarity(JUNK, COLOR_JUNK, DISPLAY_NAME_JUNK);
EnumHelperClient.addRarity(NORMAL, COLOR_NORMAL, DISPLAY_NAME_NORMAL);
EnumHelperClient.addRarity(UNCOMMON, COLOR_UNCOMMON, DISPLAY_NAME_UNCOMMON);
@ -69,6 +83,7 @@ public class ClientProxy extends CommonProxy {
@Override
public EnumRarity getCustomRarityType(String customRarity) {
for (EnumRarity rarity : EnumRarity.class.getEnumConstants()) {
if (rarity.name().equals(customRarity))
return rarity;
@ -78,9 +93,10 @@ public class ClientProxy extends CommonProxy {
@Override
public void initRenderingAndTextures() {
RenderIds.calcinatorRenderId = RenderingRegistry.getNextAvailableRenderId();
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET);
RenderIds.calcinatorRenderId = RenderingRegistry.getNextAvailableRenderId();
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.BLOCK_SPRITE_SHEET);
MinecraftForgeClient.preloadTexture(Reference.SPRITE_SHEET_LOCATION + Reference.ITEM_SPRITE_SHEET);
FMLClientHandler.instance().getClient().renderEngine.registerTextureFX(new TextureRedWaterFX());
@ -91,9 +107,10 @@ public class ClientProxy extends CommonProxy {
@Override
public void initTileEntities() {
super.initTileEntities();
ClientRegistry.bindTileEntitySpecialRenderer(TileCalcinator.class, new RenderCalcinator());
super.initTileEntities();
ClientRegistry.bindTileEntitySpecialRenderer(TileCalcinator.class, new RenderCalcinator());
}
}

View file

@ -1,17 +1,143 @@
package ee3.client.core.handlers;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import ee3.common.item.ItemPhilosopherStone;
import ee3.common.lib.Reference;
import net.minecraft.src.EnumMovingObjectType;
import net.minecraft.src.RenderEngine;
import net.minecraft.src.Tessellator;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.event.ForgeSubscribe;
public class DrawBlockHighlightHandler {
@ForgeSubscribe
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
RenderEngine renderEngine = event.context.renderEngine;
// TODO Magic happens here
if (event.currentItem != null) {
if (event.currentItem.getItem() instanceof ItemPhilosopherStone) {
if (event.target.typeOfHit == EnumMovingObjectType.TILE) {
drawPhilosopherStoneOverlay(event);
}
}
}
}
public void drawPhilosopherStoneOverlay(DrawBlockHighlightEvent event) {
double x = event.target.blockX + 0.5F;
double y = event.target.blockY + 0.5F;
double z = event.target.blockZ + 0.5F;
double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
int texture = event.context.renderEngine.getTexture(Reference.SPRITE_SHEET_LOCATION + "noise.png");
int xScale = 1;
int yScale = 1;
int zScale = 1;
int chargeLevel = ((ItemPhilosopherStone)event.currentItem.getItem()).getCharge(event.currentItem);
if (chargeLevel < 1) {
chargeLevel = 1;
}
if ((event.target.sideHit == 0) || (event.target.sideHit == 1)) {
xScale = chargeLevel;
zScale = chargeLevel;
}
else if ((event.target.sideHit == 2) || (event.target.sideHit == 3)) {
xScale = chargeLevel;
yScale = chargeLevel;
}
else if ((event.target.sideHit == 4) || (event.target.sideHit == 5)) {
yScale = chargeLevel;
zScale = chargeLevel;
}
float xShift = 0.1F;
float yShift = 0.1F;
float zShift = 0.1F;
if (event.target.sideHit == 0) {
xShift = 0;
yShift = -yShift;
zShift = 0;
}
else if (event.target.sideHit == 1) {
xShift = 0;
zShift = 0;
}
else if (event.target.sideHit == 2) {
xShift = 0;
yShift = 0;
if (chargeLevel > 1) {
zShift = -zShift - 1;
}
else {
zShift = -zShift;
}
}
else if (event.target.sideHit == 3) {
xShift = 0;
yShift = 0;
}
else if (event.target.sideHit == 4) {
xShift = -xShift;
yShift = 0;
zShift = 0;
}
else if (event.target.sideHit == 5) {
yShift = 0;
zShift = 0;
}
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE);
for (int i = 0; i < 6; i++) {
ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
GL11.glPushMatrix();
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
GL11.glTranslated(0, 0, 0.5f);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
renderSlidingQuad(texture, 0.75F);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(true);
}
public static void renderSlidingQuad(int texture, float transparency) {
float slide = (System.currentTimeMillis() % 3000) / 3000f;
double pulse = (double) 1 + slide;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
Tessellator tessellator = Tessellator.instance;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1, 1, 1, transparency);
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(1, 1, 1, transparency);
tessellator.addVertexWithUV(-0.5D, 0.5D, 0F, 0, pulse);
tessellator.addVertexWithUV(0.5D, 0.5D, 0F, 0, pulse);
tessellator.addVertexWithUV(0.5D, -0.5D, 0F, 1, pulse);
tessellator.addVertexWithUV(-0.5D, -0.5D, 0F, 1, pulse);
tessellator.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
}

View file

@ -3,7 +3,6 @@ package ee3.client.core.handlers;
import java.util.EnumSet;
import java.util.logging.Level;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.KeyBinding;
@ -49,7 +48,7 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
// Only operate at the end of the tick
if (tickEnd) {
// If we are not in a GUI of any kind, continue execution
if (FMLClientHandler.instance().getClient().currentScreen == null) {
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
// TODO Clean this up properly
if (kb.keyDescription == Reference.KEYBINDING_EXTRA) {
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();

View file

@ -80,7 +80,7 @@ public class EquivalentExchange3 {
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);
// Initialize the Render Tick Handler (Client only)
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
proxy.registerRenderTickHandler();
// Register the KeyBinding Handler (Client only)
proxy.registerKeyBindingHandler();

View file

@ -27,6 +27,8 @@ public class CommonProxy implements IGuiHandler {
public void registerKeyBindingHandler() {}
public void registerRenderTickHandler() {}
public void registerDrawBlockHighlightHandler() {}
public void setKeyBinding(String name, int value) {}

View file

@ -93,7 +93,6 @@ public class RenderTickHandler implements ITickHandler {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glEnable(GL11.GL_LIGHTING);
RenderItem renderItem = new RenderItem();
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, (int) (sr.getScaledWidth() - (16 * overlayScale)), (int) (sr.getScaledHeight() - (16 * overlayScale)), overlayOpacity / 2, overlayScale);
if ((currentBlock != null) && (currentBlock.getItem() instanceof ItemBlock)) {
RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, currentBlock, (int) (sr.getScaledWidth() - (16 * overlayScale) / 2 - 8), (int) (sr.getScaledHeight() - (16 * overlayScale) / 2 - 8), -90, blockScale);

View file

@ -38,7 +38,6 @@ public class TransmutationHelper {
if (nextItem != null) {
if (Block.blocksList[nextItem.itemID] != null) {
world.setBlockAndMetadataWithNotify(x, y, z, nextItem.itemID, nextItem.getItemDamage());
// TODO Send the sound event to everyone around the player, and not just play the sound on the current client
world.playSoundAtEntity(player, Sounds.TRANSMUTE, 0.5F, 1.0F);
return true;
}

View file

@ -4,10 +4,12 @@ import net.minecraft.src.ItemStack;
public interface IChargeable {
public abstract void setCharge(ItemStack stone, short charge);
public abstract short getCharge(ItemStack stack);
public abstract void increaseCharge(ItemStack stone);
public abstract void setCharge(ItemStack stack, short charge);
public abstract void decreaseCharge(ItemStack stone);
public abstract void increaseCharge(ItemStack stack);
public abstract void decreaseCharge(ItemStack stack);
}

View file

@ -0,0 +1,7 @@
package ee3.common.item;
public interface IKeyBound {
public abstract void doKeyBindingAction(String keyBinding, boolean isSneaking);
}

View file

@ -1,6 +1,5 @@
package ee3.common.item;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.ItemStack;
@ -15,6 +14,7 @@ import ee3.common.lib.Colours;
import ee3.common.lib.ConfigurationSettings;
import ee3.common.lib.CustomItemRarity;
import ee3.common.lib.GuiIds;
import ee3.common.lib.Reference;
import ee3.common.lib.Strings;
import ee3.common.network.PacketKeyPressed;
import ee3.common.network.PacketTypeHandler;
@ -28,7 +28,8 @@ import ee3.common.network.PacketTypeHandler;
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class ItemMiniumStone extends ItemEE implements ITransmutationStone {
public class ItemMiniumStone extends ItemEE
implements ITransmutationStone, IKeyBound {
public ItemMiniumStone(int id) {
super(id);
@ -86,4 +87,13 @@ public class ItemMiniumStone extends ItemEE implements ITransmutationStone {
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(keyPressed)));
}
@Override
public void doKeyBindingAction(String keyBinding, boolean isSneaking) {
if (keyBinding.equals(Reference.KEYBINDING_EXTRA)) {
System.out.println("Extra key");
}
}
}

View file

@ -12,7 +12,6 @@ import ee3.common.lib.GuiIds;
import ee3.common.lib.Strings;
import ee3.common.network.PacketKeyPressed;
import ee3.common.network.PacketTypeHandler;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.ItemStack;
@ -75,23 +74,28 @@ public class ItemPhilosopherStone extends ItemEE
}
@Override
public void setCharge(ItemStack stone, short charge) {
public short getCharge(ItemStack stack) {
return NBTHelper.getShort(stack, Strings.NBT_CHARGE_LEVEL_KEY);
}
@Override
public void setCharge(ItemStack stack, short charge) {
if (charge <= maxChargeLevel) {
NBTHelper.setShort(stone, "chargeLevel", charge);
NBTHelper.setShort(stack, Strings.NBT_CHARGE_LEVEL_KEY, charge);
}
}
@Override
public void increaseCharge(ItemStack stone) {
if (NBTHelper.getShort(stone, "chargeLevel") < maxChargeLevel) {
NBTHelper.setShort(stone, "chargeLevel", (short)(NBTHelper.getShort(stone, "chargeLevel") + 1));
public void increaseCharge(ItemStack stack) {
if (NBTHelper.getShort(stack, Strings.NBT_CHARGE_LEVEL_KEY) < maxChargeLevel) {
NBTHelper.setShort(stack, Strings.NBT_CHARGE_LEVEL_KEY, (short)(NBTHelper.getShort(stack, Strings.NBT_CHARGE_LEVEL_KEY) + 1));
}
}
@Override
public void decreaseCharge(ItemStack stone) {
if (NBTHelper.getShort(stone, "chargeLevel") > 0) {
NBTHelper.setShort(stone, "chargeLevel", (short)(NBTHelper.getShort(stone, "chargeLevel") - 1));
public void decreaseCharge(ItemStack stack) {
if (NBTHelper.getShort(stack, Strings.NBT_CHARGE_LEVEL_KEY) > 0) {
NBTHelper.setShort(stack, Strings.NBT_CHARGE_LEVEL_KEY, (short)(NBTHelper.getShort(stack, Strings.NBT_CHARGE_LEVEL_KEY) - 1));
}
}

View file

@ -15,6 +15,9 @@ public class Strings {
/* Gui related constants */
public static final String GUI_CALCINATOR_NAME = "gui.calcinator.name";
/* NBT related constants */
public static final String NBT_CHARGE_LEVEL_KEY = "chargeLevel";
/* Block name constants */
public static final String CALCINATOR_NAME = "calcinator";
public static final String RED_WATER_STILL_NAME = "redWaterStill";

View file

@ -7,6 +7,7 @@ import java.io.IOException;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ee3.common.EquivalentExchange3;
import ee3.common.item.IKeyBound;
import ee3.common.item.ITransmutationStone;
import ee3.common.lib.GuiIds;
import ee3.common.lib.ItemIds;
@ -38,7 +39,6 @@ public class PacketKeyPressed extends PacketEE {
this.key = key;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeUTF(key);
}
@ -53,9 +53,13 @@ public class PacketKeyPressed extends PacketEE {
public void execute(INetworkManager manager, Player player) {
EntityPlayer thePlayer = (EntityPlayer) player;
/*
if ((this.key.equals(Reference.KEYBINDING_EXTRA)) && (thePlayer.getCurrentEquippedItem().getItem() instanceof ITransmutationStone)) {
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
}
*/
if ((thePlayer.getCurrentEquippedItem() != null) && (thePlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound)) {
((IKeyBound) thePlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(this.key, thePlayer.isSneaking());
}
}
}

View file

@ -52,7 +52,6 @@ public class PacketTileUpdate extends PacketEE {
this.player = player;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(x);
data.writeInt(y);

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

View file

@ -14,7 +14,7 @@
<entry key="tile.calcinator.name">Calcinateur</entry>
<entry key="version.init_log_message">Lancement de la vérification de votre version par rapport à cette de reference : </entry>
<entry key="version.uninitialized">Le lancement de la vérification a échoué</entry>
<entry key="version.current">Vous utilisez la version la plus à jour pour votre version de Minecraft</entry>
<entry key="version.current">Vous utilisez la version (@REMOTE_MOD_VERSION@) la plus à jour pour votre version de Minecraft (@MINECRAFT_VERSION)</entry>
<entry key="version.outdated">Vous utilisez une verison obsolète, pensez à effecuter une mise a jour ici - @MOD_UPDATE_LOCATION@</entry>
<entry key="version.connection_error">Erreur de connexion vers la version de référence (vérifiez votre connexion internet ?)</entry>
<entry key="version.check_disabled">Verification de version désactiée</entry>

View file

@ -23,8 +23,8 @@
<entry key="itemGroup.EE3">Equivalent Exchange 3</entry>
<entry key="version.init_log_message">Start versiecontrole tegen extern versiebestand, te vinden op</entry>
<entry key="version.uninitialized">De versiecontrole is niet geslaagd (versiecontrole niet correct gestart)</entry>
<entry key="version.current">Je gebruikt momenteel de meest recente versie voor jouw Minecraft versie</entry>
<entry key="version.outdated">Je gebruikt momenteel een verouderde versie; overweeg om up te daten - @MOD_UPDATE_LOCATION@</entry>
<entry key="version.connection_error">Fout bij het verbinden met het extern versiecontrole bestand (controleer je internetverbinding)</entry>
<entry key="version.current">Je gebruikt momenteel de meest recente versie (@REMOTE_MOD_VERSION@) van Equivalent Exchange 3 voor @MINECRAFT_VERSION@</entry>
<entry key="version.outdated">Een nieuwe @MOD_NAME@ versie bestaat (@REMOTE_MOD_VERSION@) voor @MINECRAFT_VERSION@. Je vindt deze hier: @MOD_UPDATE_LOCATION@</entry>
<entry key="version.general_error">Er deed zich een fout voor tijdens de versiecontrole</entry>
<entry key="version.check_disabled">Externe versiecontrole uitgeschakeld, wordt overgeslagen</entry>
</properties>

View file

@ -4,5 +4,5 @@
<comment>Version lookup for Equivalent Exchange 3. Format is "Current Version Number|URL to update page"</comment>
<entry key="Minecraft 1.4.2">pre1a|http://goo.gl/Ria2V</entry>
<entry key="Minecraft 1.4.4">pre1b|http://goo.gl/Ria2V</entry>
<entry key="Minecraft 1.4.5">pre2|http://goo.gl/Ria2V</entry>
<entry key="Minecraft 1.4.5">pre1d|http://goo.gl/Ria2V</entry>
</properties>