mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-19 03:49:07 +00:00
Merge remote-tracking branch 'origin/master-MC1.11.2' into master-MC1.11.2
This commit is contained in:
commit
140df9ce4e
3 files changed
+52
-18
No files matched your search
@@ -1,24 +1,42 @@
|
||||
package binnie.extrabees.alveary;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class AlvearyLogicLighting extends AbstractAlvearyLogic {
|
||||
|
||||
|
||||
private final IEnergyStorage energyStorage;
|
||||
private boolean lighted;
|
||||
|
||||
|
||||
public AlvearyLogicLighting() {
|
||||
this.energyStorage = new EnergyStorage(2000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateServer(TileEntityExtraBeesAlvearyPart tile) {
|
||||
lighted = energyStorage.extractEnergy(10, false) >= 10;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return lighted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityEnergy.ENERGY ? (T) energyStorage : super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -13,23 +14,29 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
|
||||
public class AlvearyLogicTransmitter extends AbstractAlvearyLogic implements IEnergyStorage {
|
||||
|
||||
|
||||
private IEnergyStorage internalStorage;
|
||||
|
||||
|
||||
public AlvearyLogicTransmitter() {
|
||||
internalStorage = new EnergyStorage(2000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateServer(TileEntityExtraBeesAlvearyPart tile) {
|
||||
if (internalStorage.getEnergyStored() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<IEnergyStorage> esL = Lists.newArrayList();
|
||||
for (TileEntityExtraBeesAlvearyPart part : tile.getExtraBeesParts()) {
|
||||
if (part.getAlvearyLogic().getEnergyStorage() != null) {
|
||||
esL.add(part.getAlvearyLogic().getEnergyStorage());
|
||||
for (IMultiblockComponent part : tile.getConnectedComponents()) {
|
||||
if (part instanceof TileEntity) {
|
||||
if (((TileEntity) part).hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)) {
|
||||
esL.add(((TileEntity) part).getCapability(CapabilityEnergy.ENERGY, EnumFacing.UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (esL.isEmpty()) {
|
||||
@@ -52,42 +59,42 @@ public class AlvearyLogicTransmitter extends AbstractAlvearyLogic implements IEn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
return internalStorage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return internalStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return internalStorage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityEnergy.ENERGY;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -5,6 +5,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -33,6 +34,9 @@ public class BlockAlveary extends Block implements ITileEntityProvider {
|
||||
super(new MaterialBeehive(false));
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setRegistryName("alveary");
|
||||
setHardness(1);
|
||||
setHarvestLevel("axe", 0);
|
||||
setSoundType(SoundType.WOOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,4 +94,9 @@ public class BlockAlveary extends Block implements ITileEntityProvider {
|
||||
meta = meta >= 0 && meta < EnumAlvearyLogicType.VALUES.length ? meta : 0;
|
||||
return getDefaultState().withProperty(TYPE, EnumAlvearyLogicType.VALUES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user