use of pokefenn.totemic.api.totem.TotemEffect in project Totemic by TeamTotemic.
the class ModContent method createRegistries.
@SubscribeEvent
public static void createRegistries(RegistryEvent.NewRegistry event) {
// RegistryEvents are fired in alphabetic order.
// Instruments have to be registered before Ceremonies.
new RegistryBuilder<MusicInstrument>().setName(new ResourceLocation(Totemic.MOD_ID, "a_music_instruments")).setType(MusicInstrument.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
new RegistryBuilder<TotemEffect>().setName(new ResourceLocation(Totemic.MOD_ID, "b_totem_effects")).setType(TotemEffect.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
new RegistryBuilder<Ceremony>().setName(new ResourceLocation(Totemic.MOD_ID, "c_ceremonies")).setType(Ceremony.class).setMaxID(Byte.MAX_VALUE).disableSaving().create();
}
use of pokefenn.totemic.api.totem.TotemEffect in project Totemic by TeamTotemic.
the class ComponentMedicineWheel method addComponentParts.
@Override
public boolean addComponentParts(World world, Random random, StructureBoundingBox bb) {
if (averageGroundLvl < 0) {
averageGroundLvl = getAverageGroundLevel(world, bb);
if (averageGroundLvl < 0)
return true;
boundingBox.offset(0, averageGroundLvl - boundingBox.maxY + 6 - 1, 0);
}
fillWithAir(world, bb, 2, 0, 0, 6, 5, 0);
fillWithAir(world, bb, 1, 0, 1, 7, 5, 1);
fillWithAir(world, bb, 0, 0, 2, 8, 5, 6);
fillWithAir(world, bb, 1, 0, 7, 7, 5, 7);
fillWithAir(world, bb, 2, 0, 8, 6, 5, 8);
// Create Totem Pole
setBlockState(world, ModBlocks.totem_base.getDefaultState().withProperty(BlockTotemBase.WOOD, poleWood), 4, 0, 4, bb);
List<TotemEffect> totemList = new ArrayList<>(TotemicRegistries.totemEffects().getValuesCollection());
for (int i = 0; i < 5; i++) {
int x = 4, y = 1 + i, z = 4;
setBlockState(world, ModBlocks.totem_pole.getDefaultState().withProperty(BlockTotemPole.WOOD, poleWood), x, y, z, bb);
BlockPos pos = new BlockPos(getXWithOffset(x, z), getYWithOffset(y), getZWithOffset(x, z));
if (bb.isVecInside(pos))
((TileTotemPole) world.getTileEntity(pos)).setEffect(totemList.get(random.nextInt(totemList.size())));
}
// Place music instruments and torches
setBlockState(world, ModBlocks.drum.getDefaultState(), 4, 0, 0, bb);
setBlockState(world, ModBlocks.drum.getDefaultState(), 0, 0, 4, bb);
setBlockState(world, ModBlocks.drum.getDefaultState(), 8, 0, 4, bb);
for (int i = 0; i < 3; i++) setBlockState(world, ModBlocks.cedar_log.getDefaultState(), 4, i, 8, bb);
setBlockState(world, ModBlocks.cedar_log.getDefaultState().withProperty(BlockCedarLog.LOG_AXIS, EnumAxis.Z), 4, 3, 8, bb);
setBlockState(world, ModBlocks.cedar_log.getDefaultState().withProperty(BlockCedarLog.LOG_AXIS, EnumAxis.Z), 4, 3, 7, bb);
setBlockState(world, ModBlocks.wind_chime.getDefaultState(), 4, 2, 7, bb);
if (!isZombieInfested) {
setBlockState(world, ModBlocks.totem_torch.getDefaultState(), 1, 0, 1, bb);
setBlockState(world, ModBlocks.totem_torch.getDefaultState(), 7, 0, 1, bb);
setBlockState(world, ModBlocks.totem_torch.getDefaultState(), 7, 0, 7, bb);
setBlockState(world, ModBlocks.totem_torch.getDefaultState(), 1, 0, 7, bb);
}
// Clear above and make ground level
IBlockState ground = (structureType != 1) ? Blocks.DIRT.getDefaultState() : Blocks.SAND.getDefaultState();
IBlockState grass = getBiomeSpecificBlockState(Blocks.GRASS.getDefaultState());
for (int z = 0; z < 9; z++) for (int x = 0; x < 9; x++) {
// Only replace inside the circle
if ((x == 0 || x == 8) && (z <= 1 || z >= 7) || (x == 1 || x == 7) && (z == 0 || z == 8))
continue;
clearCurrentPositionBlocksUpwards(world, x, 6, z, bb);
replaceAirAndLiquidDownwards(world, ground, x, -1, z, bb);
if (getBlockStateFromPos(world, x, -1, z, bb).getBlock() == Blocks.DIRT)
setBlockState(world, grass, x, -1, z, bb);
}
// Create Medicine Wheel
IBlockState cobble = getBiomeSpecificBlockState(Blocks.COBBLESTONE.getDefaultState());
if (cobble.getBlock() == Blocks.SANDSTONE)
cobble = Blocks.RED_SANDSTONE.getDefaultState();
fillWithBlocks(world, bb, 4, -1, 0, 4, -1, 8, cobble, cobble, false);
fillWithBlocks(world, bb, 0, -1, 4, 8, -1, 4, cobble, cobble, false);
setBlockState(world, cobble, 5, -1, 0, bb);
setBlockState(world, cobble, 6, -1, 0, bb);
setBlockState(world, cobble, 7, -1, 1, bb);
setBlockState(world, cobble, 8, -1, 2, bb);
setBlockState(world, cobble, 8, -1, 3, bb);
setBlockState(world, cobble, 8, -1, 5, bb);
setBlockState(world, cobble, 8, -1, 6, bb);
setBlockState(world, cobble, 7, -1, 7, bb);
setBlockState(world, cobble, 6, -1, 8, bb);
setBlockState(world, cobble, 5, -1, 8, bb);
setBlockState(world, cobble, 3, -1, 8, bb);
setBlockState(world, cobble, 2, -1, 8, bb);
setBlockState(world, cobble, 1, -1, 7, bb);
setBlockState(world, cobble, 0, -1, 6, bb);
setBlockState(world, cobble, 0, -1, 5, bb);
setBlockState(world, cobble, 0, -1, 3, bb);
setBlockState(world, cobble, 0, -1, 2, bb);
setBlockState(world, cobble, 1, -1, 1, bb);
setBlockState(world, cobble, 2, -1, 0, bb);
setBlockState(world, cobble, 3, -1, 0, bb);
spawnVillagers(world, bb, 4, 1, 2, 1);
return true;
}
use of pokefenn.totemic.api.totem.TotemEffect in project Totemic by TeamTotemic.
the class TotemKnifeItem method useOn.
@SuppressWarnings("resource")
@Override
public InteractionResult useOn(UseOnContext c) {
if (c.getPlayer().isCrouching()) {
// TODO
return InteractionResult.FAIL;
} else {
BlockState state = c.getLevel().getBlockState(c.getClickedPos());
TotemWoodType woodType = TotemWoodType.fromLog(state);
if (woodType == null) {
// Fall back to oak if it is an unrecognized log type
if (BlockTags.LOGS_THAT_BURN.contains(state.getBlock()))
woodType = TotemWoodType.OAK;
else
return InteractionResult.FAIL;
}
BlockState newState;
TotemEffect effect = getCarvingEffect(c.getItemInHand());
if (effect != null) {
newState = ModBlocks.getTotemPoles().get(woodType, effect).getStateForPlacement(new BlockPlaceContext(c));
} else {
newState = ModBlocks.getTotemBases().get(woodType).getStateForPlacement(new BlockPlaceContext(c));
}
c.getLevel().setBlock(c.getClickedPos(), newState, 3);
newState.getBlock().setPlacedBy(c.getLevel(), c.getClickedPos(), newState, c.getPlayer(), c.getItemInHand());
c.getItemInHand().hurtAndBreak(1, c.getPlayer(), player -> player.broadcastBreakEvent(c.getHand()));
c.getLevel().playSound(c.getPlayer(), c.getClickedPos(), SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
return InteractionResult.sidedSuccess(c.getLevel().isClientSide);
}
}
use of pokefenn.totemic.api.totem.TotemEffect 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.api.totem.TotemEffect 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