use of pokefenn.totemic.block.totem.TotemPoleBlock in project Totemic by TeamTotemic.
the class TileTotemBase method calculateTotemEffects.
private void calculateTotemEffects() {
totemEffectList.clear();
totemEffects.clear();
for (int i = 0; i < TotemEffectAPI.MAX_POLE_SIZE; i++) {
Block block = level.getBlockState(worldPosition.above(i + 1)).getBlock();
if (block instanceof TotemPoleBlock) {
TotemEffect effect = ((TotemPoleBlock) block).effect;
totemEffectList.add(effect);
totemEffects.add(effect);
} else
break;
}
// Calculate the greatest common divisor of all the intervals of the effects
commonTotemEffectInterval = totemEffects.elementSet().stream().mapToInt(TotemEffect::getInterval).filter(// Integer.MAX_VALUE is a prime number, so we don't want it in the GCD calculation
i -> i != Integer.MAX_VALUE).reduce(IntMath::gcd).orElse(Integer.MAX_VALUE);
}
use of pokefenn.totemic.block.totem.TotemPoleBlock in project Totemic by TeamTotemic.
the class ModBlocks method init.
@SubscribeEvent
public static void init(RegistryEvent.Register<Block> event) {
internallyRegisterTotemEffects();
for (TotemWoodType woodType : TotemWoodType.getWoodTypes()) {
Properties blockProperties = Properties.of(Material.WOOD, woodType.getWoodColor()).strength(2, 5).sound(SoundType.WOOD);
TotemBaseBlock totemBase = new TotemBaseBlock(woodType, blockProperties);
totemBase.setRegistryName(Totemic.MOD_ID, woodType.getName() + "_totem_base");
event.getRegistry().register(totemBase);
totemBases.put(woodType, totemBase);
blocksWithItemBlock.add(totemBase);
for (TotemEffect totemEffect : totemEffectsToRegister) {
TotemPoleBlock totemPole = new TotemPoleBlock(woodType, totemEffect, blockProperties);
totemPole.setRegistryName(Totemic.MOD_ID, woodType.getName() + "_totem_pole_" + totemEffect.getRegistryName().getPath());
event.getRegistry().register(totemPole);
totemPoles.put(woodType, totemEffect, totemPole);
blocksWithItemBlock.add(totemPole);
}
}
}
Aggregations