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)));
}
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);
}
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);
}
}
}
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();
}
Aggregations