use of net.minecraft.world.level.block.Block in project MyPet by xXKeyleXx.
the class EntityMyTraderLlama method updateVisuals.
@Override
public void updateVisuals() {
this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest());
this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
if (getMyPet().hasDecor()) {
ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor());
Block block = Block.byItem(is.getItem());
int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0;
this.getEntityData().set(COLOR_WATCHER, color);
} else {
this.getEntityData().set(COLOR_WATCHER, -1);
}
this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant());
}
use of net.minecraft.world.level.block.Block in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showBlockAction.
@Override
public void showBlockAction(Player player, Location location, int action, int state) {
BlockPos position = new BlockPos(location.getX(), location.getY(), location.getZ());
Block block = ((CraftWorld) location.getWorld()).getHandle().getBlockState(position).getBlock();
send(player, new ClientboundBlockEventPacket(position, block, action, state));
}
use of net.minecraft.world.level.block.Block in project MinecraftForge by MinecraftForge.
the class ForgeBlockTagsProvider method addColored.
private void addColored(Consumer<Block> consumer, Tag.Named<Block> group, String pattern) {
String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
for (DyeColor color : DyeColor.values()) {
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
Tag.Named<Block> tag = getForgeTag(prefix + color.getName());
Block block = ForgeRegistries.BLOCKS.getValue(key);
if (block == null || block == Blocks.AIR)
throw new IllegalStateException("Unknown vanilla block: " + key.toString());
tag(tag).add(block);
consumer.accept(block);
}
}
use of net.minecraft.world.level.block.Block in project MinecraftForge by MinecraftForge.
the class FluidUtil method getFluidHandler.
/**
* Helper method to get an IFluidHandler for at a block position.
*/
public static LazyOptional<IFluidHandler> getFluidHandler(Level world, BlockPos blockPos, @Nullable Direction side) {
BlockState state = world.getBlockState(blockPos);
Block block = state.getBlock();
if (state.hasBlockEntity()) {
BlockEntity blockEntity = world.getBlockEntity(blockPos);
if (blockEntity != null) {
return blockEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
}
}
return LazyOptional.empty();
}
use of net.minecraft.world.level.block.Block in project MyPet by xXKeyleXx.
the class EntityMyLlama method updateVisuals.
@Override
public void updateVisuals() {
this.getEntityData().set(CHEST_WATCHER, getMyPet().hasChest());
this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
if (getMyPet().hasDecor()) {
ItemStack is = CraftItemStack.asNMSCopy(getMyPet().getDecor());
Block block = Block.byItem(is.getItem());
int color = block instanceof WoolCarpetBlock ? ((WoolCarpetBlock) block).getColor().getId() : 0;
this.getEntityData().set(COLOR_WATCHER, color);
} else {
this.getEntityData().set(COLOR_WATCHER, -1);
}
this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant());
}
Aggregations