Remove PropolisPipe (Moved to BC Compat) and update BC API version

This commit is contained in:
mezz committed 2015-09-23 03:08:45 -07:00
1 parent 77f5130604
commit bfd49b107d
15 files changed
+1 -1304

No files matched your search

@@ -1,43 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes;
import java.util.Locale;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.core.config.ForestryItem;
import forestry.core.render.TextureManager;
public enum EnumFilterType {
CLOSED, ANYTHING, ITEM, BEE, DRONE, PRINCESS, QUEEN, PURE_BREED, NOCTURNAL, PURE_NOCTURNAL, FLYER, PURE_FLYER, CAVE, PURE_CAVE, NATURAL;
public static EnumFilterType getType(ItemStack stack) {
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
return DRONE;
}
if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
return PRINCESS;
}
if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
return QUEEN;
}
return ITEM;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return TextureManager.getInstance().getDefault("analyzer/" + this.toString().toLowerCase(Locale.ENGLISH));
}
}
@@ -1,74 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.api.apiculture.BeeManager;
import forestry.core.network.GuiId;
import forestry.pipes.gui.ContainerPropolisPipe;
import forestry.pipes.gui.GuiPropolisPipe;
import buildcraft.transport.Pipe;
import buildcraft.transport.TileGenericPipe;
public class GuiHandlerPipes implements IGuiHandler {
@SuppressWarnings("rawtypes")
private static Pipe getPipe(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile == null) {
return null;
}
if (!(tile instanceof TileGenericPipe)) {
return null;
}
return ((TileGenericPipe) tile).pipe;
}
@Override
@SuppressWarnings("rawtypes")
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id >= GuiId.values().length) {
return null;
}
switch (GuiId.values()[id]) {
case PropolisPipeGUI:
return new GuiPropolisPipe(player, (PipeItemsPropolis) getPipe(world, x, y, z));
default:
return null;
}
}
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id >= GuiId.values().length) {
return null;
}
switch (GuiId.values()[id]) {
case PropolisPipeGUI:
BeeManager.beeRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
return new ContainerPropolisPipe(player.inventory, (PipeItemsPropolis) getPipe(world, x, y, z));
default:
return null;
}
}
}
@@ -1,43 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.core.render.TextureManager;
import buildcraft.api.core.IIconProvider;
public class PipeIconProvider implements IIconProvider {
private static IIcon[] icons;
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int iconIndex) {
return icons[iconIndex];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icons = new IIcon[7];
icons[0] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.empty");
icons[1] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.black");
icons[2] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.white");
icons[3] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.red");
icons[4] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.blue");
icons[5] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.green");
icons[6] = TextureManager.getInstance().registerTex(iconRegister, "pipes/pipe_prop.yellow");
}
}
@@ -1,179 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes;
import java.util.ArrayList;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.IAllele;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import buildcraft.api.core.IIconProvider;
import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.TransportConstants;
import buildcraft.transport.pipes.events.PipeEventItem;
public class PipeItemsPropolis extends Pipe<PipeTransportItems> {
public final PipeLogicPropolis pipeLogic;
public PipeItemsPropolis(Item item) {
super(new PipeTransportItems(), item);
pipeLogic = new PipeLogicPropolis(this);
transport.allowBouncing = true;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
pipeLogic.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
pipeLogic.writeToNBT(nbt);
}
IIconProvider provider;
@SideOnly(Side.CLIENT)
@Override
public IIconProvider getIconProvider() {
if (provider == null) {
provider = new PipeIconProvider();
}
return provider;
}
@Override
public int getIconIndex(ForgeDirection direction) {
if (direction == ForgeDirection.UNKNOWN) {
return 0;
}
return direction.ordinal() + 1;
}
@Override
public boolean blockActivated(EntityPlayer player) {
if (!Proxies.common.isSimulating(getWorld())) {
return true;
}
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() != null) {
if (Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) {
return false;
}
}
player.openGui(ForestryAPI.instance, GuiId.PropolisPipeGUI.ordinal(), player.worldObj, container.xCoord, container.yCoord, container.zCoord);
return true;
}
public void eventHandler(PipeEventItem.FindDest event) {
LinkedList<ForgeDirection> filteredOrientations = new LinkedList<ForgeDirection>();
LinkedList<ForgeDirection> typedOrientations = new LinkedList<ForgeDirection>();
LinkedList<ForgeDirection> defaultOrientations = new LinkedList<ForgeDirection>();
// We need a bee!
EnumFilterType type = EnumFilterType.getType(event.item.getItemStack());
IBee bee = null;
if (type != EnumFilterType.ITEM) {
bee = BeeManager.beeRoot.getMember(event.item.getItemStack());
}
// Filtered outputs
for (ForgeDirection dir : event.destinations) {
// Continue if this direction is closed.
if (pipeLogic.isClosed(dir)) {
continue;
}
if (pipeLogic.isIndiscriminate(dir)) {
defaultOrientations.add(dir);
continue;
}
// We need to match the type for this orientation's filter
if (!pipeLogic.matchType(dir, type, bee)) {
continue;
}
// Passing the type filter is enough for non-bee items.
if (type == EnumFilterType.ITEM) {
filteredOrientations.add(dir);
continue;
}
ArrayList<IAllele[]> filters = pipeLogic.getGenomeFilters(dir);
// If we have no genome filters, this is only a typed route.
if (filters.size() <= 0) {
typedOrientations.add(dir);
continue;
}
// Bees need to match one of the genome filters
for (IAllele[] pattern : filters) {
if (matchAllele(pattern[0], bee.getIdent()) && matchAllele(pattern[1], bee.getGenome().getSecondary().getUID())) {
filteredOrientations.add(dir);
}
}
}
event.destinations.clear();
if (filteredOrientations.size() > 0) {
event.destinations.addAll(filteredOrientations);
} else if (typedOrientations.size() > 0) {
event.destinations.addAll(typedOrientations);
} else {
event.destinations.addAll(defaultOrientations);
}
}
private static boolean matchAllele(IAllele filter, String ident) {
if (filter == null) {
return true;
} else {
return filter.getUID().equals(ident);
}
}
public void eventHandler(PipeEventItem.Entered event) {
// A bit of speed to perhaps prevent bees from popping out of the pipe.
try {
event.item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED * 20F);
} catch (Throwable ignored) {
}
}
public void eventHandler(PipeEventItem.AdjustSpeed event) {
transport.defaultReajustSpeed(event.item);
}
}
@@ -1,217 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IBee;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.core.network.PacketNBT;
import forestry.core.proxy.Proxies;
import forestry.pipes.network.PacketGenomeFilterChange;
import forestry.pipes.network.PacketTypeFilterChange;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeTransportItems;
public class PipeLogicPropolis {
private final Pipe<PipeTransportItems> pipe;
private final EnumFilterType[] typeFilter = new EnumFilterType[6];
private final IAllele[][][] genomeFilter = new IAllele[6][3][2];
public PipeLogicPropolis(Pipe<PipeTransportItems> pipe) {
this.pipe = pipe;
for (int i = 0; i < typeFilter.length; i++) {
typeFilter[i] = EnumFilterType.CLOSED;
}
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
for (int i = 0; i < typeFilter.length; i++) {
typeFilter[i] = EnumFilterType.values()[nbttagcompound.getByte("TypeFilter" + i)];
}
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 3; j++) {
if (nbttagcompound.hasKey("GenomeFilterS" + i + '-' + j + '-' + 0)) {
genomeFilter[i][j][0] = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("GenomeFilterS" + i + '-' + j + '-' + 0));
}
if (nbttagcompound.hasKey("GenomeFilterS" + i + '-' + j + '-' + 1)) {
genomeFilter[i][j][1] = AlleleManager.alleleRegistry.getAllele(nbttagcompound.getString("GenomeFilterS" + i + '-' + j + '-' + 1));
}
}
}
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
for (int i = 0; i < typeFilter.length; i++) {
nbttagcompound.setByte("TypeFilter" + i, (byte) typeFilter[i].ordinal());
}
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 3; j++) {
if (genomeFilter[i][j][0] != null) {
nbttagcompound.setString("GenomeFilterS" + i + '-' + j + '-' + 0, genomeFilter[i][j][0].getUID());
}
if (genomeFilter[i][j][1] != null) {
nbttagcompound.setString("GenomeFilterS" + i + '-' + j + '-' + 1, genomeFilter[i][j][1].getUID());
}
}
}
}
public boolean isClosed(ForgeDirection orientation) {
return typeFilter[orientation.ordinal()] == EnumFilterType.CLOSED;
}
public boolean isIndiscriminate(ForgeDirection orientation) {
return typeFilter[orientation.ordinal()] == EnumFilterType.ANYTHING;
}
public boolean matchType(ForgeDirection orientation, EnumFilterType type, IBee bee) {
EnumFilterType filter = typeFilter[orientation.ordinal()];
if (filter == EnumFilterType.BEE) {
return type != EnumFilterType.ITEM && type != EnumFilterType.CLOSED;
}
// Special bee filtering
if (bee != null) {
if (filter == EnumFilterType.PURE_BREED) {
return bee.isPureBred(EnumBeeChromosome.SPECIES);
}
if (filter == EnumFilterType.NOCTURNAL) {
return bee.getGenome().getNocturnal();
}
if (filter == EnumFilterType.PURE_NOCTURNAL) {
return bee.getGenome().getNocturnal() && bee.isPureBred(EnumBeeChromosome.NOCTURNAL);
}
if (filter == EnumFilterType.FLYER) {
return bee.getGenome().getTolerantFlyer();
}
if (filter == EnumFilterType.PURE_FLYER) {
return bee.getGenome().getTolerantFlyer() && bee.isPureBred(EnumBeeChromosome.TOLERANT_FLYER);
}
if (filter == EnumFilterType.CAVE) {
return bee.getGenome().getCaveDwelling();
}
if (filter == EnumFilterType.PURE_CAVE) {
return bee.getGenome().getCaveDwelling() && bee.isPureBred(EnumBeeChromosome.CAVE_DWELLING);
}
if (filter == EnumFilterType.NATURAL) {
return bee.isNatural();
}
}
// Compare the remaining
return filter == type;
}
public ArrayList<IAllele[]> getGenomeFilters(ForgeDirection orientation) {
ArrayList<IAllele[]> filters = new ArrayList<IAllele[]>();
for (int i = 0; i < 3; i++) {
if (genomeFilter[orientation.ordinal()][i] != null
&& (genomeFilter[orientation.ordinal()][i][0] != null || genomeFilter[orientation.ordinal()][i][1] != null)) {
filters.add(genomeFilter[orientation.ordinal()][i]);
}
}
return filters;
}
public EnumFilterType getTypeFilter(ForgeDirection orientation) {
return typeFilter[orientation.ordinal()];
}
public void setTypeFilter(ForgeDirection orientation, EnumFilterType type) {
typeFilter[orientation.ordinal()] = type;
if (!Proxies.common.isSimulating(pipe.getWorld())) {
sendTypeFilterChange(orientation, type);
}
}
public IAlleleSpecies getSpeciesFilter(ForgeDirection orientation, int pattern, int allele) {
if (genomeFilter[orientation.ordinal()] == null) {
return null;
}
if (genomeFilter[orientation.ordinal()].length <= pattern) {
return null;
}
if (genomeFilter[orientation.ordinal()][pattern] == null) {
return null;
}
if (genomeFilter[orientation.ordinal()][pattern].length <= allele) {
return null;
}
return (IAlleleSpecies) genomeFilter[orientation.ordinal()][pattern][allele];
}
public void setSpeciesFilter(ForgeDirection orientation, int pattern, int allele, IAllele species) {
genomeFilter[orientation.ordinal()][pattern][allele] = species;
if (!Proxies.common.isSimulating(pipe.getWorld())) {
sendGenomeFilterChange(orientation, pattern, allele, species);
}
}
/* NETWORK */
public void sendFilterSet(EntityPlayer player) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
Proxies.net.sendToPlayer(new PacketNBT(PacketId.PROP_SEND_FILTER_SET, nbttagcompound), player);
}
public void handleFilterSet(PacketNBT packet) {
this.readFromNBT(packet.getTagCompound());
}
public void requestFilterSet() {
Proxies.net.sendToServer(new PacketCoordinates(PacketId.PROP_REQUEST_FILTER_SET, pipe.container));
}
public void sendTypeFilterChange(ForgeDirection orientation, EnumFilterType filter) {
PacketTypeFilterChange packet = new PacketTypeFilterChange(pipe.container, orientation, filter);
Proxies.net.sendToServer(packet);
}
public void handleTypeFilterChange(PacketTypeFilterChange packet) {
int orientation = packet.getOrientation();
int filterOrdinal = packet.getFilter();
typeFilter[orientation] = EnumFilterType.values()[filterOrdinal];
}
public void sendGenomeFilterChange(ForgeDirection orientation, int pattern, int allele, IAllele species) {
PacketGenomeFilterChange packet = new PacketGenomeFilterChange(pipe.container, orientation, pattern, allele, species);
Proxies.net.sendToServer(packet);
}
public void handleGenomeFilterChange(PacketGenomeFilterChange packet) {
IAllele species = packet.getSpecies();
int orientation = packet.getOrientation();
int pattern = packet.getPattern();
int allele = packet.getAllele();
genomeFilter[orientation][pattern][allele] = species;
}
}
@@ -1,41 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package forestry.pipes.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import forestry.pipes.PipeItemsPropolis;
import forestry.pipes.PipeLogicPropolis;
public class ContainerPropolisPipe extends Container {
public final PipeLogicPropolis pipeLogic;
public ContainerPropolisPipe(IInventory playerInventory, PipeItemsPropolis pipe) {
this.pipeLogic = pipe.pipeLogic;
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 9; k1++) {
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18));
}
}
for (int i1 = 0; i1 < 9; i1++) {
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 198));
}
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
}
@@ -1,253 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes.gui;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.items.ItemBeeGE;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.genetics.ItemGE;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.widgets.Widget;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StringUtil;
import forestry.pipes.EnumFilterType;
import forestry.pipes.PipeItemsPropolis;
import forestry.pipes.PipeLogicPropolis;
/**
* GuiScreen for propolis pipes.
*
* @author SirSengir
*/
public class GuiPropolisPipe extends GuiForestry<ContainerPropolisPipe, IInventory> {
class TypeFilterSlot extends Widget {
private final ForgeDirection orientation;
private final PipeLogicPropolis logic;
public TypeFilterSlot(int x, int y, ForgeDirection orientation, PipeLogicPropolis logic) {
super(widgetManager, x, y);
this.orientation = orientation;
this.logic = logic;
}
public EnumFilterType getType() {
return logic.getTypeFilter(orientation);
}
@Override
public void draw(int startX, int startY) {
EnumFilterType type = logic.getTypeFilter(orientation);
IIcon icon = null;
if (type != null) {
icon = type.getIcon();
}
if (icon == null) {
return;
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
Proxies.common.bindTexture(SpriteSheet.ITEMS);
drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, icon, 16, 16);
}
@Override
protected String getLegacyTooltip(EntityPlayer player) {
EnumFilterType type = logic.getTypeFilter(orientation);
return StringUtil.localize("gui.pipe.filter." + type.toString().toLowerCase(Locale.ENGLISH));
}
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
EnumFilterType change;
if (mouseButton == 1) {
change = EnumFilterType.CLOSED;
} else if (getType().ordinal() < EnumFilterType.values().length - 1) {
change = EnumFilterType.values()[getType().ordinal() + 1];
} else {
change = EnumFilterType.CLOSED;
}
pipeLogic.setTypeFilter(orientation, change);
}
}
class SpeciesFilterSlot extends Widget {
private final IApiaristTracker tracker;
private final ForgeDirection orientation;
private final PipeLogicPropolis logic;
private final int pattern;
private final int allele;
public SpeciesFilterSlot(IApiaristTracker tracker, int x, int y, ForgeDirection orientation, int pattern, int allele, PipeLogicPropolis logic) {
super(widgetManager, x, y);
this.tracker = tracker;
this.orientation = orientation;
this.pattern = pattern;
this.allele = allele;
this.logic = logic;
}
public IAlleleSpecies getSpecies() {
return logic.getSpeciesFilter(orientation, pattern, allele);
}
public boolean isDefined() {
IAlleleSpecies species = logic.getSpeciesFilter(orientation, pattern, allele);
return species != null;
}
@Override
public void draw(int startX, int startY) {
if (!isDefined()) {
return;
}
IAlleleSpecies species = logic.getSpeciesFilter(orientation, pattern, allele);
GL11.glDisable(GL11.GL_LIGHTING);
for (int i = 0; i < 3; ++i) {
IIcon icon = ((ItemBeeGE) ForestryItem.beeDroneGE.item()).getIconFromSpecies((IAlleleBeeSpecies) species, i);
int color = ((ItemGE) ForestryItem.beeDroneGE.item()).getColourFromSpecies(species, i);
float colorR = (color >> 16 & 255) / 255.0F;
float colorG = (color >> 8 & 255) / 255.0F;
float colorB = (color & 255) / 255.0F;
GL11.glColor4f(colorR, colorG, colorB, 1.0F);
// drawTexturedModalRect(startX + xPos, startY + yPos, iconIndex % 16 * 16, iconIndex / 16 * 16, 16, 16);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, icon, 16, 16);
}
GL11.glEnable(GL11.GL_LIGHTING);
}
@Override
protected String getLegacyTooltip(EntityPlayer player) {
IAlleleSpecies species = logic.getSpeciesFilter(orientation, pattern, allele);
if (species != null) {
return species.getName();
} else {
return null;
}
}
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
IAlleleSpecies change = null;
if (mouseButton == 1) {
change = null;
} else if (getSpecies() == null) {
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (!(entry.getValue() instanceof IAlleleBeeSpecies)) {
continue;
}
change = (IAlleleBeeSpecies) entry.getValue();
break;
}
} else {
Iterator<Entry<String, IAllele>> it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator();
while (it.hasNext()) {
Entry<String, IAllele> entry = it.next();
if (!(entry.getValue() instanceof IAlleleBeeSpecies)) {
continue;
}
IAlleleBeeSpecies species = (IAlleleBeeSpecies) entry.getValue();
if (!species.getUID().equals(getSpecies().getUID())) {
continue;
}
while (it.hasNext()) {
Entry<String, IAllele> entry2 = it.next();
if (!(entry2.getValue() instanceof IAlleleBeeSpecies)) {
continue;
}
IAlleleBeeSpecies next = (IAlleleBeeSpecies) entry2.getValue();
if (!Config.isDebug && next.isSecret() && !tracker.isDiscovered(next)) {
continue;
}
change = next;
break;
}
break;
}
}
pipeLogic.setSpeciesFilter(orientation, pattern, allele, change);
}
}
private final PipeLogicPropolis pipeLogic;
public GuiPropolisPipe(EntityPlayer player, PipeItemsPropolis pipe) {
super(Defaults.TEXTURE_PATH_GUI + "/analyzer.png", new ContainerPropolisPipe(player.inventory, pipe), null);
pipeLogic = pipe.pipeLogic;
// Request filter set update if on client
if (!Proxies.common.isSimulating(pipe.getWorld())) {
pipeLogic.requestFilterSet();
}
xSize = 175;
ySize = 225;
for (int i = 0; i < 6; i++) {
widgetManager.add(new TypeFilterSlot(8, 18 + i * 18, ForgeDirection.values()[i], pipeLogic));
}
IApiaristTracker tracker = BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
for (int i = 0; i < 6; i++) {
for (int pattern = 0; pattern < 3; pattern++) {
for (int allele = 0; allele < 2; allele++) {
int x = 44 + pattern * 45 + allele * 18;
int y = 18 + i * 18;
widgetManager.add(new SpeciesFilterSlot(tracker, x, y, ForgeDirection.values()[i], pattern, allele, pipeLogic));
}
}
}
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRendererObj.drawString("Apiarist's Pipe", 56, 6, 0x303030);
}
}
@@ -1,86 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.pipes.network;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
public class PacketGenomeFilterChange extends PacketCoordinates {
private int orientation;
private int pattern;
private int allele;
private String species;
public PacketGenomeFilterChange(DataInputStreamForestry data) throws IOException {
super(data);
}
public PacketGenomeFilterChange(TileEntity tile, ForgeDirection orientation, int pattern, int allele, IAllele species) {
super(PacketId.PROP_SEND_FILTER_CHANGE_GENOME, tile);
this.orientation = orientation.ordinal();
this.pattern = pattern;
this.allele = allele;
if (species != null) {
this.species = species.getUID();
} else {
this.species = "";
}
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeShort(orientation);
data.writeShort(pattern);
data.writeShort(allele);
data.writeUTF(species);
}
@Override
protected void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
orientation = data.readShort();
pattern = data.readShort();
allele = data.readShort();
species = data.readUTF();
}
public int getOrientation() {
return orientation;
}
public int getPattern() {
return pattern;
}
public int getAllele() {
return allele;
}
public IAllele getSpecies() {
if (species.length() == 0) {
return null;
}
return AlleleManager.alleleRegistry.getAllele(species);
}
}
@@ -1,120 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes.network;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.ILocatedPacket;
import forestry.core.network.IPacketHandler;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.core.network.PacketNBT;
import forestry.core.proxy.Proxies;
import forestry.pipes.PipeItemsPropolis;
import forestry.pipes.PipeLogicPropolis;
import forestry.pipes.gui.ContainerPropolisPipe;
import buildcraft.transport.Pipe;
import buildcraft.transport.TileGenericPipe;
public class PacketHandlerPipes implements IPacketHandler {
private static Pipe getPipe(World world, ILocatedPacket packet) {
TileEntity tile = packet.getTarget(world);
if (!(tile instanceof TileGenericPipe)) {
return null;
}
return ((TileGenericPipe) tile).pipe;
}
@Override
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
switch (packetID) {
// CLIENT
case PROP_SEND_FILTER_SET: {
PacketNBT packet = new PacketNBT(data);
onFilterSet(packet);
return true;
}
// SERVER
case PROP_REQUEST_FILTER_SET: {
PacketCoordinates packet = new PacketCoordinates(data);
onRequestFilterSet(player, packet);
return true;
}
case PROP_SEND_FILTER_CHANGE_TYPE: {
PacketTypeFilterChange packet = new PacketTypeFilterChange(data);
onTypeFilterChange(player, packet);
return true;
}
case PROP_SEND_FILTER_CHANGE_GENOME: {
PacketGenomeFilterChange packet = new PacketGenomeFilterChange(data);
onGenomeFilterChange(player, packet);
return true;
}
}
return false;
}
private static void onFilterSet(PacketNBT packet) {
Container container = Proxies.common.getClientInstance().thePlayer.openContainer;
if (container instanceof ContainerPropolisPipe) {
PipeLogicPropolis pipeLogic = ((ContainerPropolisPipe) container).pipeLogic;
pipeLogic.handleFilterSet(packet);
}
}
private static void onTypeFilterChange(EntityPlayer player, PacketTypeFilterChange packet) {
Pipe pipe = getPipe(player.worldObj, packet);
if (pipe == null) {
return;
}
if (pipe instanceof PipeItemsPropolis) {
((PipeItemsPropolis) pipe).pipeLogic.handleTypeFilterChange(packet);
}
}
private static void onGenomeFilterChange(EntityPlayer player, PacketGenomeFilterChange packet) {
Pipe pipe = getPipe(player.worldObj, packet);
if (pipe == null) {
return;
}
if (pipe instanceof PipeItemsPropolis) {
((PipeItemsPropolis) pipe).pipeLogic.handleGenomeFilterChange(packet);
}
}
private static void onRequestFilterSet(EntityPlayer player, PacketCoordinates packet) {
Pipe pipe = getPipe(player.worldObj, packet);
if (pipe == null) {
return;
}
if (pipe instanceof PipeItemsPropolis) {
((PipeItemsPropolis) pipe).pipeLogic.sendFilterSet(player);
}
}
}
@@ -1,61 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.pipes.network;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.pipes.EnumFilterType;
public class PacketTypeFilterChange extends PacketCoordinates {
private int orientation;
private int filter;
public PacketTypeFilterChange(DataInputStreamForestry data) throws IOException {
super(data);
}
public PacketTypeFilterChange(TileEntity tile, ForgeDirection orientation, EnumFilterType filter) {
super(PacketId.PROP_SEND_FILTER_CHANGE_TYPE, tile);
this.orientation = orientation.ordinal();
this.filter = filter.ordinal();
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeShort(orientation);
data.writeShort(filter);
}
@Override
protected void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
orientation = data.readShort();
filter = data.readShort();
}
public int getOrientation() {
return orientation;
}
public int getFilter() {
return filter;
}
}
@@ -1,31 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes.proxy;
import net.minecraft.item.Item;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import forestry.plugins.PluginPropolisPipe;
import buildcraft.transport.TransportProxyClient;
public class ClientProxyPipes extends ProxyPipes {
@Override
public void registerCustomItemRenderer(Item item, IItemRenderer basemod) {
MinecraftForgeClient.registerItemRenderer(item, basemod);
}
@Override
public void initPropolisPipe() {
super.initPropolisPipe();
registerCustomItemRenderer(PluginPropolisPipe.pipeItemsPropolis, TransportProxyClient.pipeItemRenderer);
}
}
@@ -1,75 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.pipes.proxy;
import java.lang.reflect.Constructor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.pipes.PipeItemsPropolis;
import forestry.plugins.PluginPropolisPipe;
import buildcraft.BuildCraftTransport;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.ItemPipe;
import buildcraft.transport.Pipe;
import buildcraft.transport.TransportProxy;
public class ProxyPipes {
public void registerCustomItemRenderer(Item item, IItemRenderer basemod) {
}
public void initPropolisPipe() {
PluginPropolisPipe.pipeItemsPropolis = createPipe(PipeItemsPropolis.class, CreativeTabBuildCraft.PIPES);
}
@SuppressWarnings("rawtypes")
public static Item createPipe(Class<? extends Pipe> clas, CreativeTabBuildCraft creativeTab) {
return registerPipe(clas, creativeTab);
}
/**
* Overriding the method in BlockGenericPipe to fix localizations.
*/
@SuppressWarnings("rawtypes")
public static ItemPipe registerPipe(Class<? extends Pipe> clas, CreativeTabBuildCraft creativeTab) {
ItemPipe item = null;
try {
Constructor<ItemPipe> ctor = ItemPipe.class.getDeclaredConstructor(CreativeTabBuildCraft.class);
ctor.setAccessible(true);
item = ctor.newInstance(creativeTab);
} catch (Exception e) {
e.printStackTrace();
}
assert item != null : "The ItemPipe instance must not be null";
item.setUnlocalizedName(clas.getSimpleName());
GameRegistry.registerItem(item, item.getUnlocalizedName());
BlockGenericPipe.pipes.put(item, clas);
Pipe dummyPipe = BlockGenericPipe.createPipe(item);
if (dummyPipe != null) {
item.setPipeIconIndex(dummyPipe.getIconIndexForItem());
TransportProxy.proxy.setIconProviderFromPipe(item, dummyPipe);
}
return item;
}
public static void registerCraftingPropolis(ItemStack resource) {
GameRegistry.addRecipe(new ItemStack(PluginPropolisPipe.pipeItemsPropolis), "#X#", '#', resource, 'X', BuildCraftTransport.pipeItemsDiamond);
}
}
@@ -83,7 +83,6 @@ public class PluginManager {
BUILDCRAFT_RECIPES(new PluginBuildCraftRecipes()),
BUILDCRAFT_STATEMENTS(new PluginBuildCraftStatements()),
BUILDCRAFT_TRANSPORT(new PluginBuildCraftTransport()),
PROPOLIS_PIPE(new PluginPropolisPipe()),
AGRICRAFT(new PluginAgriCraft()),
BIOMESOPLENTY(new PluginBiomesOPlenty()),
@@ -1,79 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 by SirSengir
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/.
******************************************************************************/
package forestry.plugins;
import java.util.EnumSet;
import net.minecraft.item.Item;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.network.IPacketHandler;
import forestry.core.proxy.Proxies;
import forestry.pipes.GuiHandlerPipes;
import forestry.pipes.network.PacketHandlerPipes;
import forestry.pipes.proxy.ProxyPipes;
@Plugin(pluginID = "Pipes", name = "Pipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.pipes.description")
public class PluginPropolisPipe extends ForestryPlugin {
public static ProxyPipes proxy;
/**
* Pipe used to sort bees from Forestry.
*/
public static Item pipeItemsPropolis;
@Override
public boolean isAvailable() {
return Proxies.common.isModLoaded("BuildCraft|Transport") &&
Proxies.common.isModLoaded("BuildCraft|Core", "[6.0, 7.0)");
}
@Override
public String getFailMessage() {
return "BuildCraft|Transport not found";
}
@Override
public EnumSet<PluginManager.Module> getDependancies() {
EnumSet<PluginManager.Module> deps = super.getDependancies();
deps.add(PluginManager.Module.APICULTURE);
return deps;
}
@Override
public void postInit() {
String proxyClass = "forestry.pipes.proxy.ProxyPipes";
if (FMLCommonHandler.instance().getSide().isClient()) {
proxyClass = "forestry.pipes.proxy.ClientProxyPipes";
}
proxy = (ProxyPipes) Proxies.common.instantiateIfModLoaded("BuildCraft|Transport", proxyClass);
if (proxy == null) {
return;
}
proxy.initPropolisPipe();
ProxyPipes.registerCraftingPropolis(ForestryItem.propolis.getItemStack());
}
@Override
public IGuiHandler getGuiHandler() {
return new GuiHandlerPipes();
}
@Override
public IPacketHandler getPacketHandler() {
return new PacketHandlerPipes();
}
}