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:
parent
2cd5558f8f
commit
62872b13ee
14 changed files with 133 additions and 15 deletions
|
@ -13,6 +13,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
import ee3.client.core.helper.KeyBindingHelper;
|
import ee3.client.core.helper.KeyBindingHelper;
|
||||||
import ee3.common.EquivalentExchange3;
|
import ee3.common.EquivalentExchange3;
|
||||||
|
import ee3.common.item.ITransmutationStone;
|
||||||
import ee3.common.item.ModItems;
|
import ee3.common.item.ModItems;
|
||||||
import ee3.common.lib.GuiIds;
|
import ee3.common.lib.GuiIds;
|
||||||
import ee3.common.lib.Reference;
|
import ee3.common.lib.Reference;
|
||||||
|
@ -50,13 +51,8 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
|
||||||
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
|
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
|
||||||
|
|
||||||
if (currentItem != null) {
|
if (currentItem != null) {
|
||||||
if ((currentItem.getItem().shiftedIndex == ModItems.miniumStone.shiftedIndex) || (currentItem.getItem().shiftedIndex == ModItems.philStone.shiftedIndex)) {
|
if (currentItem.getItem() instanceof ITransmutationStone) {
|
||||||
// Notify the Server that we opened the GUI
|
((ITransmutationStone)currentItem.getItem()).openPortableCrafting(kb.keyDescription);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class CreativeTabEE3 extends CreativeTabs {
|
||||||
* the itemID for the item to be displayed on the tab
|
* the itemID for the item to be displayed on the tab
|
||||||
*/
|
*/
|
||||||
public int getTabIconItemIndex() {
|
public int getTabIconItemIndex() {
|
||||||
return ItemIds.PHILOSOPHER_STONE;
|
return ItemIds.MINIUM_SHARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class EntityLivingHandler {
|
||||||
|
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
public void onEntityLivingUpdate(LivingUpdateEvent event) {
|
public void onEntityLivingUpdate(LivingUpdateEvent event) {
|
||||||
|
/* Disabled because of horribly inefficient code
|
||||||
EntityLiving entity = event.entityLiving;
|
EntityLiving entity = event.entityLiving;
|
||||||
|
|
||||||
if (entity.worldObj.getWorldTime() % 4 == 0) {
|
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));
|
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
|
@ForgeSubscribe
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class VersionCheckTickHandler implements ITickHandler {
|
||||||
if (tickType == TickType.CLIENT) {
|
if (tickType == TickType.CLIENT) {
|
||||||
if (FMLClientHandler.instance().getClient().currentScreen == null) {
|
if (FMLClientHandler.instance().getClient().currentScreen == null) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
if (VersionHelper.result != VersionHelper.CURRENT){
|
||||||
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(Colours.VERSION_CHECK_PREFIX + "[" + Reference.MOD_NAME + "] " + VersionHelper.getResultMessage());
|
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
|
@Override
|
||||||
public EnumSet<TickType> ticks() {
|
public EnumSet<TickType> ticks() {
|
||||||
|
|
|
@ -3,6 +3,22 @@ package ee3.common.core.helper;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.src.Block;
|
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.Item;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
|
|
||||||
|
@ -41,4 +57,27 @@ public class GeneralHelper {
|
||||||
return list.toArray();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ItemDropHelper {
|
||||||
private static double rand;
|
private static double rand;
|
||||||
|
|
||||||
public static void dropMiniumShard(EntityPlayer player, EntityLiving entity) {
|
public static void dropMiniumShard(EntityPlayer player, EntityLiving entity) {
|
||||||
if (!(entity instanceof EntityAgeable) && !(entity instanceof EntityPlayer)) {
|
if (GeneralHelper.isHostileEntity(entity)) {
|
||||||
rand = Math.random();
|
rand = Math.random();
|
||||||
|
|
||||||
if (rand < 0.15d) {
|
if (rand < 0.15d) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class TransmutationHelper {
|
||||||
if (nextItem != null) {
|
if (nextItem != null) {
|
||||||
if (Block.blocksList[nextItem.itemID] != null) {
|
if (Block.blocksList[nextItem.itemID] != null) {
|
||||||
world.setBlockAndMetadataWithNotify(x, y, z, nextItem.itemID, nextItem.getItemDamage());
|
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);
|
world.playSoundAtEntity(player, Sounds.TRANSMUTE, 0.5F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
13
ee3_common/ee3/common/item/IChargeable.java
Normal file
13
ee3_common/ee3/common/item/IChargeable.java
Normal 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);
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,6 @@ package ee3.common.item;
|
||||||
*/
|
*/
|
||||||
public interface ITransmutationStone {
|
public interface ITransmutationStone {
|
||||||
|
|
||||||
public abstract void openPortableCraftingGui();
|
public abstract void openPortableCrafting(String keyPressed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
package ee3.common.item;
|
package ee3.common.item;
|
||||||
|
|
||||||
|
import net.minecraft.src.EntityClientPlayerMP;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.EnumRarity;
|
import net.minecraft.src.EnumRarity;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.common.Side;
|
import cpw.mods.fml.common.Side;
|
||||||
import cpw.mods.fml.common.asm.SideOnly;
|
import cpw.mods.fml.common.asm.SideOnly;
|
||||||
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import ee3.common.EquivalentExchange3;
|
import ee3.common.EquivalentExchange3;
|
||||||
import ee3.common.core.helper.TransmutationHelper;
|
import ee3.common.core.helper.TransmutationHelper;
|
||||||
import ee3.common.lib.Colours;
|
import ee3.common.lib.Colours;
|
||||||
import ee3.common.lib.ConfigurationSettings;
|
import ee3.common.lib.ConfigurationSettings;
|
||||||
import ee3.common.lib.CustomItemRarity;
|
import ee3.common.lib.CustomItemRarity;
|
||||||
|
import ee3.common.lib.GuiIds;
|
||||||
|
import ee3.common.network.PacketKeyPressed;
|
||||||
|
import ee3.common.network.PacketTypeHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemMiniumStone
|
* ItemMiniumStone
|
||||||
|
@ -21,7 +27,7 @@ import ee3.common.lib.CustomItemRarity;
|
||||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
* @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) {
|
public ItemMiniumStone(int id) {
|
||||||
super(id);
|
super(id);
|
||||||
|
@ -73,4 +79,13 @@ public class ItemMiniumStone extends ItemEE {
|
||||||
return false;
|
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)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
package ee3.common.item;
|
package ee3.common.item;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.common.Side;
|
import cpw.mods.fml.common.Side;
|
||||||
import cpw.mods.fml.common.asm.SideOnly;
|
import cpw.mods.fml.common.asm.SideOnly;
|
||||||
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import ee3.common.EquivalentExchange3;
|
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.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.EnumRarity;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemPhilosopherStone
|
* ItemPhilosopherStone
|
||||||
|
@ -16,10 +26,14 @@ import net.minecraft.src.ItemStack;
|
||||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
* @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) {
|
public ItemPhilosopherStone(int id) {
|
||||||
super(id);
|
super(id);
|
||||||
|
maxChargeLevel = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
@ -42,4 +56,39 @@ public class ItemPhilosopherStone extends ItemEE {
|
||||||
return true;
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||||
import cpw.mods.fml.common.network.Player;
|
import cpw.mods.fml.common.network.Player;
|
||||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
import ee3.common.EquivalentExchange3;
|
import ee3.common.EquivalentExchange3;
|
||||||
|
import ee3.common.item.ITransmutationStone;
|
||||||
import ee3.common.lib.GuiIds;
|
import ee3.common.lib.GuiIds;
|
||||||
import ee3.common.lib.ItemIds;
|
import ee3.common.lib.ItemIds;
|
||||||
import ee3.common.lib.Reference;
|
import ee3.common.lib.Reference;
|
||||||
|
@ -53,7 +54,7 @@ public class PacketKeyPressed extends PacketEE {
|
||||||
public void execute(INetworkManager manager, Player player) {
|
public void execute(INetworkManager manager, Player player) {
|
||||||
EntityPlayer thePlayer = (EntityPlayer) 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);
|
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 |
Binary file not shown.
Loading…
Reference in a new issue