Search in sources :

Example 1 with TotemTopBlock

use of de.teamlapen.vampirism.blocks.TotemTopBlock in project Werewolves by TeamLapen.

the class ModBlocks method registerBlocks.

static void registerBlocks(IForgeRegistry<Block> registry) {
    registry.register(prepareRegister(new OreBlock(Block.Properties.of(Material.STONE).strength(3.0F, 5.0F))).setRegistryName(REFERENCE.MODID, "silver_ore"));
    WolfsbaneBlock wolfsbane = new WolfsbaneBlock();
    registry.register(prepareRegister(wolfsbane));
    registry.register(prepareRegister(new Block(Block.Properties.of(Material.METAL, MaterialColor.METAL).strength(5.0F, 6.0F).sound(SoundType.METAL)).setRegistryName(REFERENCE.MODID, "silver_block")));
    registry.register(prepareRegister(new FlowerPotBlock(wolfsbane, Block.Properties.of(Material.DECORATION).strength(0f)).setRegistryName(REFERENCE.MODID, "potted_wolfsbane")));
    registry.register(prepareRegister(new TotemTopBlock(false, REFERENCE.WEREWOLF_PLAYER_KEY).setRegistryName(REFERENCE.MODID, "totem_top_werewolves_werewolf")));
    registry.register(prepareRegister(new TotemTopBlock(true, REFERENCE.WEREWOLF_PLAYER_KEY).setRegistryName(REFERENCE.MODID, "totem_top_werewolves_werewolf_crafted")));
    registry.register(prepareRegister(new LeavesBlock(Block.Properties.of(Material.LEAVES).strength(0.2F).randomTicks().sound(SoundType.GRASS).noOcclusion()).setRegistryName(REFERENCE.MODID, "jacaranda_leaves")));
    registry.register(prepareRegister(new ModSaplingBlock(new JacarandaTree()).setRegistryName(REFERENCE.MODID, "jacaranda_sapling")));
    Block log1 = BlocksInvoker.createLogBlock_werewolves(MaterialColor.COLOR_BROWN, MaterialColor.COLOR_BROWN).setRegistryName(REFERENCE.MODID, "jacaranda_log");
    ((FireBlockInvoker) Blocks.FIRE).invokeSetFireInfo_werewolves(log1, 5, 5);
    registry.register(prepareRegister(log1));
    registry.register(prepareRegister(new LeavesBlock(Block.Properties.of(Material.LEAVES).strength(0.2F).randomTicks().sound(SoundType.GRASS).noOcclusion()).setRegistryName(REFERENCE.MODID, "magic_leaves")));
    registry.register(prepareRegister(new ModSaplingBlock(new MagicTree()).setRegistryName(REFERENCE.MODID, "magic_sapling")));
    Block log2 = BlocksInvoker.createLogBlock_werewolves(MaterialColor.COLOR_BLUE, MaterialColor.COLOR_BLUE).setRegistryName(REFERENCE.MODID, "magic_log");
    ((FireBlockInvoker) Blocks.FIRE).invokeSetFireInfo_werewolves(log2, 5, 5);
    registry.register(prepareRegister(log2));
    registry.register(prepareRegister(new Block(Block.Properties.of(Material.WOOD, MaterialColor.WOOD).strength(2.0F, 3.0F).sound(SoundType.WOOD)).setRegistryName(REFERENCE.MODID, "magic_planks")));
    registry.register(prepareRegister(new StoneAltarBlock().setRegistryName(REFERENCE.MODID, StoneAltarBlock.REG_NAME)));
    registry.register(prepareRegister(new StoneAltarFireBowlBlock().setRegistryName(REFERENCE.MODID, StoneAltarFireBowlBlock.REG_NAME)));
}
Also used : StoneAltarBlock(de.teamlapen.werewolves.blocks.StoneAltarBlock) StoneAltarFireBowlBlock(de.teamlapen.werewolves.blocks.StoneAltarFireBowlBlock) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) JacarandaTree(de.teamlapen.werewolves.world.JacarandaTree) WolfsbaneBlock(de.teamlapen.werewolves.blocks.WolfsbaneBlock) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) ModSaplingBlock(de.teamlapen.werewolves.blocks.ModSaplingBlock) WolfsbaneBlock(de.teamlapen.werewolves.blocks.WolfsbaneBlock) StoneAltarFireBowlBlock(de.teamlapen.werewolves.blocks.StoneAltarFireBowlBlock) StoneAltarBlock(de.teamlapen.werewolves.blocks.StoneAltarBlock) FireBlockInvoker(de.teamlapen.werewolves.mixin.FireBlockInvoker) MagicTree(de.teamlapen.werewolves.world.MagicTree) ModSaplingBlock(de.teamlapen.werewolves.blocks.ModSaplingBlock)

Example 2 with TotemTopBlock

use of de.teamlapen.vampirism.blocks.TotemTopBlock in project Vampirism by TeamLapen.

the class ModBlocksRender method registerColorsUnsafe.

public static void registerColorsUnsafe() {
    BlockColors colors = Minecraft.getInstance().getBlockColors();
    colors.register((state, worldIn, pos, tintIndex) -> {
        if (tintIndex == 1) {
            return 0x9966FF;
        }
        return 0x8855FF;
    }, ModBlocks.alchemical_fire);
    colors.register((state, worldIn, pos, tintIndex) -> {
        if (tintIndex == 255) {
            TileEntity tile = (worldIn == null || pos == null) ? null : worldIn.getBlockEntity(pos);
            if (tile instanceof AlchemicalCauldronTileEntity) {
                return ((AlchemicalCauldronTileEntity) tile).getLiquidColorClient();
            }
        }
        return 0xFFFFFF;
    }, ModBlocks.alchemical_cauldron);
    colors.register((state, worldIn, pos, tintIndex) -> {
        if (tintIndex == 255) {
            TileEntity tile = (worldIn == null || pos == null) ? null : worldIn.getBlockEntity(pos);
            if (tile instanceof TotemTileEntity) {
                IFaction f = ((TotemTileEntity) tile).getControllingFaction();
                if (f != null)
                    return f.getColor().getRGB();
            }
        }
        return 0xFFFFFF;
    }, TotemTopBlock.getBlocks().toArray(new TotemTopBlock[0]));
    colors.register((state, worldIn, pos, tintIndex) -> {
        return 0x1E1F1F;
    }, ModBlocks.dark_spruce_leaves);
}
Also used : TotemTileEntity(de.teamlapen.vampirism.tileentity.TotemTileEntity) AlchemicalCauldronTileEntity(de.teamlapen.vampirism.tileentity.AlchemicalCauldronTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) TotemTileEntity(de.teamlapen.vampirism.tileentity.TotemTileEntity) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) IFaction(de.teamlapen.vampirism.api.entity.factions.IFaction) BlockColors(net.minecraft.client.renderer.color.BlockColors) AlchemicalCauldronTileEntity(de.teamlapen.vampirism.tileentity.AlchemicalCauldronTileEntity)

Example 3 with TotemTopBlock

use of de.teamlapen.vampirism.blocks.TotemTopBlock in project Vampirism by TeamLapen.

the class TotemTileEntity method setControllingFaction.

private void setControllingFaction(@Nullable IFaction<?> faction) {
    this.controllingFaction = faction;
    this.baseColors = faction != null ? faction.getColor().getColorComponents(null) : DyeColor.WHITE.getTextureDiffuseColors();
    if (this.level != null) {
        BlockState oldBlockState = this.getBlockState();
        Block b = oldBlockState.getBlock();
        boolean crafted = b instanceof TotemTopBlock && ((TotemTopBlock) b).isCrafted();
        BlockState newBlockState = (faction == null ? crafted ? ModBlocks.totem_top_crafted : ModBlocks.totem_top : faction.getVillageData().getTotemTopBlock(crafted)).defaultBlockState();
        try {
            // https://github.com/TeamLapen/Vampirism/issues/793 no idea what might cause this
            this.level.setBlock(this.worldPosition, newBlockState, 55);
        } catch (IllegalStateException e) {
            LOGGER.error("Setting blockstate from {} to {}", oldBlockState, newBlockState);
            LOGGER.error("Failed to set totem blockstate", e);
        }
    }
}
Also used : BlockState(net.minecraft.block.BlockState) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) Block(net.minecraft.block.Block) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) BushBlock(net.minecraft.block.BushBlock) TotemBaseBlock(de.teamlapen.vampirism.blocks.TotemBaseBlock)

Example 4 with TotemTopBlock

use of de.teamlapen.vampirism.blocks.TotemTopBlock in project Vampirism by TeamLapen.

the class TotemTileEntity method updateTileStatus.

/**
 * updates the tile status and determines the related {@link PointOfInterest}s
 * <p>
 * this includes checking if the totem is placed in a village, the totem is complete, if there is another totem and forces a faction
 */
public void updateTileStatus() {
    if (!(this.level instanceof ServerWorld))
        return;
    Block b = this.level.getBlockState(this.worldPosition).getBlock();
    if (!(this.isComplete = b instanceof TotemTopBlock && this.level.getBlockState(this.worldPosition.below()).getBlock().equals(ModBlocks.totem_base)))
        return;
    ResourceLocation blockFaction = ((TotemTopBlock) b).faction;
    if (!(blockFaction.equals(this.controllingFaction == null ? nonFactionTotem : this.controllingFaction.getID()))) {
        // If block faction does not match tile faction, force the tile to update to the block faction
        this.forcedFaction = VampirismAPI.factionRegistry().getFactionByID(blockFaction);
    }
    Set<PointOfInterest> points = TotemHelper.getVillagePointsOfInterest((ServerWorld) level, this.worldPosition);
    if (!(this.isInsideVillage = !points.isEmpty())) {
        this.village = Collections.emptySet();
        if (this.controllingFaction != null) {
            this.setControllingFaction(null);
        }
    } else if (!(7 == TotemHelper.isVillage(points, (ServerWorld) this.level, this.worldPosition, this.controllingFaction != null || this.capturingFaction != null))) {
        this.isInsideVillage = false;
        this.village = Collections.emptySet();
        if (this.controllingFaction != null) {
            this.setControllingFaction(null);
        }
    } else if (!(this.isDisabled = !TotemHelper.addTotem((ServerWorld) this.level, points, this.worldPosition))) {
        this.village.removeIf(points::contains);
        TotemHelper.removeTotem(this.level.dimension(), this.village, this.worldPosition, false);
        this.village = points;
    } else {
        this.village = Collections.emptySet();
    }
    this.setChanged();
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) PointOfInterest(net.minecraft.village.PointOfInterest) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) TotemTopBlock(de.teamlapen.vampirism.blocks.TotemTopBlock) BushBlock(net.minecraft.block.BushBlock) TotemBaseBlock(de.teamlapen.vampirism.blocks.TotemBaseBlock)

Aggregations

TotemTopBlock (de.teamlapen.vampirism.blocks.TotemTopBlock)4 TotemBaseBlock (de.teamlapen.vampirism.blocks.TotemBaseBlock)2 Block (net.minecraft.block.Block)2 BushBlock (net.minecraft.block.BushBlock)2 IFaction (de.teamlapen.vampirism.api.entity.factions.IFaction)1 AlchemicalCauldronTileEntity (de.teamlapen.vampirism.tileentity.AlchemicalCauldronTileEntity)1 TotemTileEntity (de.teamlapen.vampirism.tileentity.TotemTileEntity)1 ModSaplingBlock (de.teamlapen.werewolves.blocks.ModSaplingBlock)1 StoneAltarBlock (de.teamlapen.werewolves.blocks.StoneAltarBlock)1 StoneAltarFireBowlBlock (de.teamlapen.werewolves.blocks.StoneAltarFireBowlBlock)1 WolfsbaneBlock (de.teamlapen.werewolves.blocks.WolfsbaneBlock)1 FireBlockInvoker (de.teamlapen.werewolves.mixin.FireBlockInvoker)1 JacarandaTree (de.teamlapen.werewolves.world.JacarandaTree)1 MagicTree (de.teamlapen.werewolves.world.MagicTree)1 BlockState (net.minecraft.block.BlockState)1 BlockColors (net.minecraft.client.renderer.color.BlockColors)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 PointOfInterest (net.minecraft.village.PointOfInterest)1 ServerWorld (net.minecraft.world.server.ServerWorld)1