mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Add a way to get all the Alveary components from the Alveary Controller
This commit is contained in:
1 parent
6845a0f71b
commit
0a79ead98d
3 files changed
+53
-30
No files matched your search
@@ -64,6 +64,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
private final Set<IBeeListener> beeListeners = new HashSet<IBeeListener>();
|
||||
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<IAlvearyComponent.Climatiser>();
|
||||
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<IAlvearyComponent.Active>();
|
||||
private final Set<IAlvearyComponent> allComponents = new HashSet<IAlvearyComponent>();
|
||||
|
||||
// CLIENT
|
||||
private int breedingProgressPercent = 0;
|
||||
@@ -101,6 +102,11 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
return beeModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IAlvearyComponent> getComponents() {
|
||||
return allComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data) {
|
||||
this.readFromNBT(data);
|
||||
@@ -108,47 +114,55 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
protected void onBlockAdded(IMultiblockPart newPart) {
|
||||
if (newPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) newPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
beeModifiers.add(beeModifier);
|
||||
}
|
||||
if (newPart instanceof IAlvearyComponent) {
|
||||
allComponents.add((IAlvearyComponent) newPart);
|
||||
|
||||
if (newPart instanceof IAlvearyComponent.BeeListener) {
|
||||
IAlvearyComponent.BeeListener beeListenerSource = (IAlvearyComponent.BeeListener) newPart;
|
||||
IBeeListener beeListener = beeListenerSource.getBeeListener();
|
||||
beeListeners.add(beeListener);
|
||||
}
|
||||
if (newPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) newPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
beeModifiers.add(beeModifier);
|
||||
}
|
||||
|
||||
if (newPart instanceof IAlvearyComponent.Climatiser) {
|
||||
climatisers.add((IAlvearyComponent.Climatiser) newPart);
|
||||
}
|
||||
if (newPart instanceof IAlvearyComponent.BeeListener) {
|
||||
IAlvearyComponent.BeeListener beeListenerSource = (IAlvearyComponent.BeeListener) newPart;
|
||||
IBeeListener beeListener = beeListenerSource.getBeeListener();
|
||||
beeListeners.add(beeListener);
|
||||
}
|
||||
|
||||
if (newPart instanceof IAlvearyComponent.Active) {
|
||||
activeComponents.add((IAlvearyComponent.Active) newPart);
|
||||
if (newPart instanceof IAlvearyComponent.Climatiser) {
|
||||
climatisers.add((IAlvearyComponent.Climatiser) newPart);
|
||||
}
|
||||
|
||||
if (newPart instanceof IAlvearyComponent.Active) {
|
||||
activeComponents.add((IAlvearyComponent.Active) newPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBlockRemoved(IMultiblockPart oldPart) {
|
||||
if (oldPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) oldPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
beeModifiers.remove(beeModifier);
|
||||
}
|
||||
if (oldPart instanceof IAlvearyComponent) {
|
||||
allComponents.remove(oldPart);
|
||||
|
||||
if (oldPart instanceof IAlvearyComponent.BeeListener) {
|
||||
IAlvearyComponent.BeeListener beeListenerSource = (IAlvearyComponent.BeeListener) oldPart;
|
||||
IBeeListener beeListener = beeListenerSource.getBeeListener();
|
||||
beeListeners.remove(beeListener);
|
||||
}
|
||||
if (oldPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) oldPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
beeModifiers.remove(beeModifier);
|
||||
}
|
||||
|
||||
if (oldPart instanceof IAlvearyComponent.Climatiser) {
|
||||
climatisers.remove(oldPart);
|
||||
}
|
||||
if (oldPart instanceof IAlvearyComponent.BeeListener) {
|
||||
IAlvearyComponent.BeeListener beeListenerSource = (IAlvearyComponent.BeeListener) oldPart;
|
||||
IBeeListener beeListener = beeListenerSource.getBeeListener();
|
||||
beeListeners.remove(beeListener);
|
||||
}
|
||||
|
||||
if (oldPart instanceof IAlvearyComponent.Active) {
|
||||
activeComponents.remove(oldPart);
|
||||
if (oldPart instanceof IAlvearyComponent.Climatiser) {
|
||||
climatisers.remove(oldPart);
|
||||
}
|
||||
|
||||
if (oldPart instanceof IAlvearyComponent.Active) {
|
||||
activeComponents.remove(oldPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
@@ -54,6 +55,11 @@ public class FakeAlvearyController implements IAlvearyController {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IAlvearyComponent> getComponents() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return FakeBeeHousingInventory.instance;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
@@ -20,5 +21,7 @@ import forestry.core.network.IStreamableGui;
|
||||
public interface IAlvearyController extends IBeeHousing, IClimatised, IRestrictedAccessTile, IStreamableGui {
|
||||
IInventoryAdapter getInternalInventory();
|
||||
|
||||
Iterable<IAlvearyComponent> getComponents();
|
||||
|
||||
int getHealthScaled(int i);
|
||||
}
|
||||
Reference in new issue
Block a user