use of net.minecraft.resources.ResourceLocation in project Tropicraft by Tropicraft.
the class Sounds method register.
private static SoundEvent register(String soundPath) {
ResourceLocation resLoc = new ResourceLocation(Constants.MODID, soundPath);
SoundEvent soundEvent = new SoundEvent(resLoc);
ForgeRegistries.SOUND_EVENTS.register(soundEvent.setRegistryName(resLoc));
if (registeredSounds.contains(soundPath)) {
System.out.println("TCWARNING: duplicate sound registration for " + soundPath);
}
registeredSounds.add(soundPath);
return soundEvent;
}
use of net.minecraft.resources.ResourceLocation in project MC-Prefab by Brian-Wuest.
the class Structure method WaterReplacedWithCobbleStone.
/**
* Determines if a water block was replaced with cobblestone because this structure was built in the nether or the
* end.
*
* @param configuration The structure configuration.
* @param block The build block object.
* @param world The workd object.
* @param originalPos The original block position this structure was built on.
* @param foundBlock The actual block found at the current location.
* @param blockState The block state to set for the current block.
* @param player The player requesting this build.
* @return Returns true if the water block was replaced by cobblestone, otherwise false.
*/
protected Boolean WaterReplacedWithCobbleStone(StructureConfiguration configuration, BuildBlock block, Level world, BlockPos originalPos, Block foundBlock, BlockState blockState, Player player) {
// Replace water blocks and waterlogged blocks with cobblestone when this is not an ultra warm world type.
// Also check a configuration value to determine if water blocks are allowed in non-over-world dimensions.
boolean isOverWorld = Level.OVERWORLD.compareTo(world.dimension()) == 0;
if (world.dimensionType().ultraWarm() || (!isOverWorld && Prefab.proxy.getServerConfiguration().allowWaterInNonOverworldDimensions)) {
boolean foundWaterLikeBlock = (foundBlock instanceof LiquidBlock && blockState.getMaterial() == Material.WATER) || foundBlock instanceof SeagrassBlock;
if (!foundWaterLikeBlock) {
for (BuildProperty property : block.getProperties()) {
if (property.getName().equalsIgnoreCase(BlockStateProperties.WATERLOGGED.getName()) && property.getValue().equalsIgnoreCase(BlockStateProperties.WATERLOGGED.getName(true))) {
// Found a waterlogged block. Replace with cobblestone.
foundWaterLikeBlock = true;
break;
}
}
}
if (foundWaterLikeBlock) {
ResourceLocation cobbleIdentifier = Registry.BLOCK.getKey(Blocks.COBBLESTONE);
block.setBlockDomain(cobbleIdentifier.getNamespace());
block.setBlockName(cobbleIdentifier.getPath());
block.setBlockState(Blocks.COBBLESTONE.defaultBlockState());
BlockPos setBlockPos = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
world.setBlock(setBlockPos, block.getBlockState(), BlockFlags.DEFAULT);
return true;
}
}
return false;
}
use of net.minecraft.resources.ResourceLocation in project MC-Prefab by Brian-Wuest.
the class BlockGlassStairs method skipRendering.
@Override
@OnlyIn(Dist.CLIENT)
public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) {
Tag<Block> tags = BlockTags.getAllTags().getTag(new ResourceLocation("forge", "glass"));
Block adjacentBlock = adjacentBlockState.getBlock();
return tags.contains(adjacentBlock) || adjacentBlock == this || (adjacentBlock == ModRegistry.GlassSlab.get() && adjacentBlockState.getValue(SlabBlock.TYPE) == SlabType.DOUBLE);
}
use of net.minecraft.resources.ResourceLocation 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.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class GlobalLootModifierProvider method run.
@Override
public void run(HashCache cache) throws IOException {
start();
Path forgePath = gen.getOutputFolder().resolve("data/forge/loot_modifiers/global_loot_modifiers.json");
String modPath = "data/" + modid + "/loot_modifiers/";
List<ResourceLocation> entries = new ArrayList<>();
toSerialize.forEach(LamdbaExceptionUtils.rethrowBiConsumer((name, pair) -> {
entries.add(new ResourceLocation(modid, name));
Path modifierPath = gen.getOutputFolder().resolve(modPath + name + ".json");
JsonObject json = pair.getB();
json.addProperty("type", pair.getA().getRegistryName().toString());
DataProvider.save(GSON, cache, json, modifierPath);
}));
JsonObject forgeJson = new JsonObject();
forgeJson.addProperty("replace", this.replace);
forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(ResourceLocation::toString).collect(Collectors.toList())));
DataProvider.save(GSON, cache, forgeJson, forgePath);
}
Aggregations