Improved GUI calling for the portable crafting interface, fixing an inefficient Red Water check, get more of the PStone functionality working, and included some texture work from spikeof2010

This commit is contained in:
pahimar 2012-10-28 23:16:32 -04:00
parent 2cd5558f8f
commit 62872b13ee
14 changed files with 133 additions and 15 deletions

View file

@ -13,6 +13,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ee3.client.core.helper.KeyBindingHelper;
import ee3.common.EquivalentExchange3;
import ee3.common.item.ITransmutationStone;
import ee3.common.item.ModItems;
import ee3.common.lib.GuiIds;
import ee3.common.lib.Reference;
@ -50,13 +51,8 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
if (currentItem != null) {
if ((currentItem.getItem().shiftedIndex == ModItems.miniumStone.shiftedIndex) || (currentItem.getItem().shiftedIndex == ModItems.philStone.shiftedIndex)) {
// Notify the Server that we opened the GUI
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(kb.keyDescription)));
// Open the GUI
EntityClientPlayerMP thePlayer = FMLClientHandler.instance().getClient().thePlayer;
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
if (currentItem.getItem() instanceof ITransmutationStone) {
((ITransmutationStone)currentItem.getItem()).openPortableCrafting(kb.keyDescription);
}
}
}

View file

@ -19,7 +19,7 @@ public class CreativeTabEE3 extends CreativeTabs {
* the itemID for the item to be displayed on the tab
*/
public int getTabIconItemIndex() {
return ItemIds.PHILOSOPHER_STONE;
return ItemIds.MINIUM_SHARD;
}
}

View file

@ -24,6 +24,7 @@ public class EntityLivingHandler {
@ForgeSubscribe
public void onEntityLivingUpdate(LivingUpdateEvent event) {
/* Disabled because of horribly inefficient code
EntityLiving entity = event.entityLiving;
if (entity.worldObj.getWorldTime() % 4 == 0) {
@ -35,6 +36,7 @@ public class EntityLivingHandler {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, Reference.BLOCK_RED_WATER_EFFECT_DURATION_MODIFIER * Reference.BLOCK_RED_WATER_EFFECT_DURATION_BASE * Reference.SECOND_IN_TICKS, 0));
}
}
*/
}
@ForgeSubscribe

View file

@ -34,6 +34,7 @@ public class VersionCheckTickHandler implements ITickHandler {
if (tickType == TickType.CLIENT) {
if (FMLClientHandler.instance().getClient().currentScreen == null) {
initialized = true;
if (VersionHelper.result != VersionHelper.CURRENT){
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(Colours.VERSION_CHECK_PREFIX + "[" + Reference.MOD_NAME + "] " + VersionHelper.getResultMessage());
}
}
@ -41,6 +42,7 @@ public class VersionCheckTickHandler implements ITickHandler {
}
}
}
}
@Override
public EnumSet<TickType> ticks() {

View file

@ -3,6 +3,22 @@ package ee3.common.core.helper;
import java.util.ArrayList;
import net.minecraft.src.Block;
import net.minecraft.src.EntityBlaze;
import net.minecraft.src.EntityCaveSpider;
import net.minecraft.src.EntityCreeper;
import net.minecraft.src.EntityDragon;
import net.minecraft.src.EntityEnderman;
import net.minecraft.src.EntityGhast;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityMagmaCube;
import net.minecraft.src.EntityPigZombie;
import net.minecraft.src.EntitySilverfish;
import net.minecraft.src.EntitySkeleton;
import net.minecraft.src.EntitySlime;
import net.minecraft.src.EntitySpider;
import net.minecraft.src.EntityWitch;
import net.minecraft.src.EntityWither;
import net.minecraft.src.EntityZombie;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
@ -41,4 +57,27 @@ public class GeneralHelper {
return list.toArray();
}
public static boolean isHostileEntity(EntityLiving entity) {
if ((entity instanceof EntityBlaze) ||
(entity instanceof EntityCaveSpider) ||
(entity instanceof EntityCreeper) ||
(entity instanceof EntityDragon) ||
(entity instanceof EntityEnderman) ||
(entity instanceof EntityGhast) ||
(entity instanceof EntityMagmaCube) ||
(entity instanceof EntityPigZombie) ||
(entity instanceof EntitySilverfish) ||
(entity instanceof EntitySkeleton) ||
(entity instanceof EntitySlime) ||
(entity instanceof EntitySpider) ||
(entity instanceof EntityWitch) ||
(entity instanceof EntityWither) ||
(entity instanceof EntityZombie)) {
return true;
}
else {
return false;
}
}
}

View file

@ -19,7 +19,7 @@ public class ItemDropHelper {
private static double rand;
public static void dropMiniumShard(EntityPlayer player, EntityLiving entity) {
if (!(entity instanceof EntityAgeable) && !(entity instanceof EntityPlayer)) {
if (GeneralHelper.isHostileEntity(entity)) {
rand = Math.random();
if (rand < 0.15d) {

View file

@ -38,6 +38,7 @@ 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

@ -0,0 +1,13 @@
package ee3.common.item;
import net.minecraft.src.ItemStack;
public interface IChargeable {
public abstract void setCharge(ItemStack stone, short charge);
public abstract void increaseCharge(ItemStack stone);
public abstract void decreaseCharge(ItemStack stone);
}

View file

@ -11,6 +11,6 @@ package ee3.common.item;
*/
public interface ITransmutationStone {
public abstract void openPortableCraftingGui();
public abstract void openPortableCrafting(String keyPressed);
}

View file

@ -1,16 +1,22 @@
package ee3.common.item;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumRarity;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.network.PacketDispatcher;
import ee3.common.EquivalentExchange3;
import ee3.common.core.helper.TransmutationHelper;
import ee3.common.lib.Colours;
import ee3.common.lib.ConfigurationSettings;
import ee3.common.lib.CustomItemRarity;
import ee3.common.lib.GuiIds;
import ee3.common.network.PacketKeyPressed;
import ee3.common.network.PacketTypeHandler;
/**
* ItemMiniumStone
@ -21,7 +27,7 @@ import ee3.common.lib.CustomItemRarity;
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class ItemMiniumStone extends ItemEE {
public class ItemMiniumStone extends ItemEE implements ITransmutationStone {
public ItemMiniumStone(int id) {
super(id);
@ -73,4 +79,13 @@ public class ItemMiniumStone extends ItemEE {
return false;
}
@Override
public void openPortableCrafting(String keyPressed) {
/*
* Notify the Server that we opened the GUI. When the server receives the packet, it will open the Gui
* server side, and notify the client to open the Gui client side on its own. Magic!
*/
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(keyPressed)));
}
}

View file

@ -1,11 +1,21 @@
package ee3.common.item;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.network.PacketDispatcher;
import ee3.common.EquivalentExchange3;
import ee3.common.core.helper.NBTHelper;
import ee3.common.core.helper.TransmutationHelper;
import ee3.common.lib.CustomItemRarity;
import ee3.common.lib.GuiIds;
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;
import net.minecraft.src.World;
/**
* ItemPhilosopherStone
@ -16,10 +26,14 @@ import net.minecraft.src.ItemStack;
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class ItemPhilosopherStone extends ItemEE {
public class ItemPhilosopherStone extends ItemEE
implements ITransmutationStone, IChargeable {
private int maxChargeLevel;
public ItemPhilosopherStone(int id) {
super(id);
maxChargeLevel = 4;
}
@SideOnly(Side.CLIENT)
@ -42,4 +56,39 @@ public class ItemPhilosopherStone extends ItemEE {
return true;
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float f1, float f2, float f3) {
return TransmutationHelper.transmuteInWorld(world, entityPlayer, itemStack, x, y, z);
}
@Override
public void openPortableCrafting(String keyPressed) {
/*
* Notify the Server that we opened the GUI. When the server receives the packet, it will open the Gui
* server side, and notify the client to open the Gui client side on its own. Magic!
*/
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(keyPressed)));
}
@Override
public void setCharge(ItemStack stone, short charge) {
if (charge <= maxChargeLevel) {
NBTHelper.setShort(stone, "chargeLevel", charge);
}
}
@Override
public void increaseCharge(ItemStack stone) {
if (NBTHelper.getShort(stone, "chargeLevel") < maxChargeLevel) {
NBTHelper.setShort(stone, "chargeLevel", (short)(NBTHelper.getShort(stone, "chargeLevel") + 1));
}
}
@Override
public void decreaseCharge(ItemStack stone) {
if (NBTHelper.getShort(stone, "chargeLevel") > 0) {
NBTHelper.setShort(stone, "chargeLevel", (short)(NBTHelper.getShort(stone, "chargeLevel") - 1));
}
}
}

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.ITransmutationStone;
import ee3.common.lib.GuiIds;
import ee3.common.lib.ItemIds;
import ee3.common.lib.Reference;
@ -53,7 +54,7 @@ public class PacketKeyPressed extends PacketEE {
public void execute(INetworkManager manager, Player player) {
EntityPlayer thePlayer = (EntityPlayer) player;
if ((this.key.equals(LanguageRegistry.instance().getStringLocalization(Reference.KEYBINDING_EXTRA))) && (thePlayer.getCurrentEquippedItem().getItem().shiftedIndex == ItemIds.MINIUM_STONE)) {
if ((this.key.equals(LanguageRegistry.instance().getStringLocalization(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);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB