mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-12 00:08:01 +00:00
Basic bee ring start.
This commit is contained in:
1 parent
bdb7a53b96
commit
951df8a632
10 files changed
+429
-23
No files matched your search
+3
-2
@@ -2,8 +2,9 @@
|
||||
|
||||
dependencies {
|
||||
compile('com.github.GTNewHorizons:ForestryMC:4.5.2:dev')
|
||||
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compile('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Botania:1.9.2-GTNH:api') {transitive = false}
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive = false}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package magicbees.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerEffectRing extends Container {
|
||||
|
||||
IInventory IBR;
|
||||
|
||||
public ContainerEffectRing(IInventory IBR, EntityPlayer player) {
|
||||
this.IBR = IBR;
|
||||
this.addSlotToContainer(
|
||||
new SlotCustomItems(this.IBR, 0, 80, 22, GameRegistry.findItemStack("Forestry", "beeDroneGE", 1)));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 74 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 132));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||
Slot itemSlot = this.getSlot(slot);
|
||||
boolean clearSlot = false;
|
||||
|
||||
if (itemSlot != null && itemSlot.getHasStack()) {
|
||||
ItemStack srcStack = itemSlot.getStack();
|
||||
if (slot == 0 && srcStack != null) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 1, 36 + 1, false);
|
||||
} else {
|
||||
if (this.getSlot(0).isItemValid(srcStack)) {
|
||||
clearSlot = this.mergeItemStack(srcStack, 0, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clearSlot) {
|
||||
itemSlot.putStack(null);
|
||||
}
|
||||
itemSlot.onSlotChanged();
|
||||
player.inventory.markDirty();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package magicbees.client.gui;
|
||||
|
||||
import magicbees.item.ItemBeeRing;
|
||||
import magicbees.main.CommonProxy;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GUIEffectRing extends GuiContainer {
|
||||
|
||||
|
||||
public static final String BACKGROUND_FILE = "jarScreen.png";
|
||||
public static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(
|
||||
CommonProxy.DOMAIN,
|
||||
CommonProxy.GUI_TEXTURE + "jarScreen.png");
|
||||
|
||||
private static final int WIDTH = 176;
|
||||
private static final int HEIGHT = 156;
|
||||
|
||||
public GUIEffectRing(ItemStack itemStack, EntityPlayer player) {
|
||||
super(new ContainerEffectRing(ItemBeeRing.getInventory(player, itemStack), player));
|
||||
this.xSize = WIDTH;
|
||||
this.ySize = HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString("Inventory", 9, 63, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_SRC_ALPHA);
|
||||
this.mc.getTextureManager().bindTexture(BACKGROUND_LOCATION);
|
||||
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package magicbees.client.gui;
|
||||
|
||||
import magicbees.item.ItemBeeRing;
|
||||
import magicbees.tileentity.TileEntityEffectJar;
|
||||
import magicbees.tileentity.TileEntityMagicApiary;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import scala.swing.Applet;
|
||||
|
||||
public class GUIHandler implements IGuiHandler {
|
||||
|
||||
@@ -19,6 +22,8 @@ public class GUIHandler implements IGuiHandler {
|
||||
} else if (ID == UIScreens.THAUMIC_APIARY.ordinal()) {
|
||||
TileEntityMagicApiary tileEntityThaumicApiary = (TileEntityMagicApiary) world.getTileEntity(x, y, z);
|
||||
value = new ContainerMagicApiary(player.inventory, tileEntityThaumicApiary);
|
||||
} else if (ID == UIScreens.EFFECT_RING.ordinal()) {
|
||||
value = new ContainerEffectRing(ItemBeeRing.getInventory(player, player.getHeldItem()),player);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -31,8 +36,9 @@ public class GUIHandler implements IGuiHandler {
|
||||
} else if (ID == UIScreens.THAUMIC_APIARY.ordinal()) {
|
||||
TileEntityMagicApiary tileEntityThaumicApiary = (TileEntityMagicApiary) world.getTileEntity(x, y, z);
|
||||
return new GuiMagicApiary(player.inventory, tileEntityThaumicApiary);
|
||||
} else {
|
||||
return null;
|
||||
} else if (ID == UIScreens.EFFECT_RING.ordinal()) {
|
||||
return new GUIEffectRing(player.getHeldItem() ,player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,6 @@ package magicbees.client.gui;
|
||||
|
||||
public enum UIScreens {
|
||||
EFFECT_JAR,
|
||||
THAUMIC_APIARY,;
|
||||
THAUMIC_APIARY,
|
||||
EFFECT_RING
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package magicbees.item;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import magicbees.client.gui.UIScreens;
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.MagicBees;
|
||||
import magicbees.itemInventories.InventoryBeeRing;
|
||||
import magicbees.main.utils.MoonPhase;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
|
||||
public class ItemBeeRing extends Item implements IBauble {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon icon;
|
||||
|
||||
public ItemBeeRing()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
this.canRepair = false;
|
||||
this.setMaxDamage(0);
|
||||
this.setCreativeTab(Thaumcraft.tabTC);
|
||||
this.setUnlocalizedName("beeRing");
|
||||
GameRegistry.registerItem(this, "beeRing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (null == itemStack.getTagCompound())
|
||||
{
|
||||
onCreated(itemStack, world, player);
|
||||
}
|
||||
|
||||
if (world.isRemote) {
|
||||
player.openGui(MagicBees.object, UIScreens.EFFECT_RING.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon(CommonProxy.DOMAIN + ":beeRing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IInventory getInventory(EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
return new InventoryBeeRing(itemStack, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package magicbees.itemInventories;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class AbstractItemInventories implements IInventory {
|
||||
|
||||
protected ItemStack[] inventoryContent;
|
||||
protected int stackLimit = 64;
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (inventoryContent == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIn) {
|
||||
if (inventoryContent != null) {
|
||||
return inventoryContent[slotIn];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
ItemStack itemstack = null;
|
||||
|
||||
if (getStackInSlot(slot) != null) {
|
||||
if (getStackInSlot(slot).stackSize <= count) {
|
||||
itemstack = getStackInSlot(slot);
|
||||
setInventorySlotContents(slot, null);
|
||||
} else {
|
||||
itemstack = getStackInSlot(slot).splitStack(count);
|
||||
|
||||
if (getStackInSlot(slot).stackSize == 0) {
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
if (inventoryContent != null && slot == 1)
|
||||
{
|
||||
inventoryContent[slot] = stack;
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "BeeRing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return stackLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void markDirty();
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package magicbees.itemInventories;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class InventoryBeeRing extends AbstractItemInventories {
|
||||
|
||||
private static final String KEY_ITEMS = "Items"; // legacy
|
||||
private static final String KEY_SLOTS = "Slots";
|
||||
private static final String KEY_UID = "UID";
|
||||
private static final Random rand = new Random();
|
||||
|
||||
public int currentBeeHealth;
|
||||
private final ItemStack parent;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public InventoryBeeRing(ItemStack parent, EntityPlayer player)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.player = player;
|
||||
readFromNBT(parent.getTagCompound());
|
||||
|
||||
}
|
||||
|
||||
public boolean isParentItemInventory(ItemStack itemStack) {
|
||||
ItemStack parent = getParent();
|
||||
return isSameItemInventory(parent, itemStack);
|
||||
}
|
||||
|
||||
protected ItemStack getParent() {
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (isSameItemInventory(equipped, parent)) {
|
||||
return equipped;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
private static boolean isSameItemInventory(ItemStack base, ItemStack comparison) {
|
||||
if (base == null || comparison == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (base.getItem() != comparison.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!base.hasTagCompound() || !comparison.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String baseUID = base.getTagCompound().getString(KEY_UID);
|
||||
String comparisonUID = comparison.getTagCompound().getString(KEY_UID);
|
||||
return baseUID != null && comparisonUID != null && baseUID.equals(comparisonUID);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
if (nbt == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nbt.hasKey(KEY_SLOTS)) {
|
||||
NBTTagCompound nbtSlots = nbt.getCompoundTag(KEY_SLOTS);
|
||||
for (int i = 0; i < inventoryContent.length; i++) {
|
||||
String slotKey = getSlotNBTKey(i);
|
||||
if (nbtSlots.hasKey(slotKey)) {
|
||||
NBTTagCompound itemNbt = nbtSlots.getCompoundTag(slotKey);
|
||||
ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemNbt);
|
||||
inventoryContent[i] = itemStack;
|
||||
} else {
|
||||
inventoryContent[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeToParentNBT() {
|
||||
ItemStack parent = getParent();
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound nbt = parent.getTagCompound();
|
||||
NBTTagCompound slotsNbt = new NBTTagCompound();
|
||||
for (int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack itemStack = getStackInSlot(i);
|
||||
if (itemStack != null) {
|
||||
String slotKey = getSlotNBTKey(i);
|
||||
NBTTagCompound itemNbt = new NBTTagCompound();
|
||||
itemStack.writeToNBT(itemNbt);
|
||||
slotsNbt.setTag(slotKey, itemNbt);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setTag(KEY_SLOTS, slotsNbt);
|
||||
nbt.removeTag(KEY_ITEMS);
|
||||
}
|
||||
|
||||
private static String getSlotNBTKey(int i) {
|
||||
return Integer.toString(i, Character.MAX_RADIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
writeToParentNBT();
|
||||
}
|
||||
}
|
||||
@@ -10,24 +10,7 @@ import magicbees.block.BlockMagicApiary;
|
||||
import magicbees.block.BlockManaAuraProvider;
|
||||
import magicbees.block.BlockVisAuraProvider;
|
||||
import magicbees.block.types.HiveType;
|
||||
import magicbees.item.ItemCapsule;
|
||||
import magicbees.item.ItemComb;
|
||||
import magicbees.item.ItemDrop;
|
||||
import magicbees.item.ItemMagicHive;
|
||||
import magicbees.item.ItemMagicHiveFrame;
|
||||
import magicbees.item.ItemManasteelGrafter;
|
||||
import magicbees.item.ItemManasteelScoop;
|
||||
import magicbees.item.ItemMiscResources;
|
||||
import magicbees.item.ItemMoonDial;
|
||||
import magicbees.item.ItemMysteriousMagnet;
|
||||
import magicbees.item.ItemNugget;
|
||||
import magicbees.item.ItemPollen;
|
||||
import magicbees.item.ItemPropolis;
|
||||
import magicbees.item.ItemThaumiumGrafter;
|
||||
import magicbees.item.ItemThaumiumScoop;
|
||||
import magicbees.item.ItemVoidGrafter;
|
||||
import magicbees.item.ItemVoidScoop;
|
||||
import magicbees.item.ItemWax;
|
||||
import magicbees.item.*;
|
||||
import magicbees.item.types.CapsuleType;
|
||||
import magicbees.item.types.HiveFrameType;
|
||||
import magicbees.item.types.NuggetType;
|
||||
@@ -128,6 +111,7 @@ public class Config {
|
||||
public static ItemNugget nuggets;
|
||||
public static ItemMoonDial moonDial;
|
||||
public static ItemMysteriousMagnet magnet;
|
||||
public static ItemBeeRing beeRing;
|
||||
|
||||
public static Item voidScoop;
|
||||
public static Item voidGrafter;
|
||||
@@ -199,6 +183,8 @@ public class Config {
|
||||
miscResources = new ItemMiscResources();
|
||||
pollen = new ItemPollen();
|
||||
moonDial = new ItemMoonDial();
|
||||
beeRing = new ItemBeeRing();
|
||||
|
||||
setupJellyBaby();
|
||||
setupNuggets();
|
||||
setupMysteriousMagnet();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 271 B |
Reference in new issue
Block a user