use of net.minecraft.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class ForgeMod method registerFluids.
// done in an event instead of deferred to only enable if a mod requests it
public void registerFluids(RegistryEvent.Register<Fluid> event) {
if (enableMilkFluid) {
// set up attributes
FluidAttributes.Builder attributesBuilder = FluidAttributes.builder(new ResourceLocation("forge", "block/milk_still"), new ResourceLocation("forge", "block/milk_flowing")).density(1024).viscosity(1024);
ForgeFlowingFluid.Properties properties = new ForgeFlowingFluid.Properties(MILK, FLOWING_MILK, attributesBuilder).bucket(() -> Items.MILK_BUCKET);
// register fluids
event.getRegistry().register(new ForgeFlowingFluid.Source(properties).setRegistryName(MILK.getId()));
event.getRegistry().register(new ForgeFlowingFluid.Flowing(properties).setRegistryName(FLOWING_MILK.getId()));
}
}
use of net.minecraft.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class ForgeMod method missingSoundMapping.
public void missingSoundMapping(RegistryEvent.MissingMappings<SoundEvent> event) {
// Removed in 1.15, see https://minecraft.gamepedia.com/Parrot#History
List<String> removedSounds = Arrays.asList("entity.parrot.imitate.panda", "entity.parrot.imitate.zombie_pigman", "entity.parrot.imitate.enderman", "entity.parrot.imitate.polar_bear", "entity.parrot.imitate.wolf");
for (RegistryEvent.MissingMappings.Mapping<SoundEvent> mapping : event.getAllMappings()) {
ResourceLocation regName = mapping.key;
if (regName != null && regName.getNamespace().equals("minecraft")) {
String path = regName.getPath();
if (removedSounds.stream().anyMatch(s -> s.equals(path))) {
LOGGER.info("Ignoring removed minecraft sound {}", regName);
mapping.ignore();
}
}
}
}
use of net.minecraft.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class ForgeMod method registerLootData.
// ModBus
@SubscribeEvent
// automatically called by Forge
@SuppressWarnings("unused")
public void registerLootData(RegistryEvent.Register<GlobalLootModifierSerializer<?>> event) {
// Ignore the event itself: this is done only not to statically initialize our custom LootConditionType
Registry.register(Registry.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), LootTableIdCondition.LOOT_TABLE_ID);
Registry.register(Registry.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), CanToolPerformAction.LOOT_CONDITION_TYPE);
}
use of net.minecraft.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class CraftingHelper method getIngredient.
public static Ingredient getIngredient(JsonElement json) {
if (json == null || json.isJsonNull())
throw new JsonSyntaxException("Json cannot be null");
if (json.isJsonArray()) {
List<Ingredient> ingredients = Lists.newArrayList();
List<Ingredient> vanilla = Lists.newArrayList();
json.getAsJsonArray().forEach((ele) -> {
Ingredient ing = CraftingHelper.getIngredient(ele);
if (// Vanilla, Due to how we read it splits each itemstack, so we pull out to re-merge later
ing.getClass() == Ingredient.class)
vanilla.add(ing);
else
ingredients.add(ing);
});
if (!vanilla.isEmpty())
ingredients.add(Ingredient.merge(vanilla));
if (ingredients.size() == 0)
throw new JsonSyntaxException("Item array cannot be empty, at least one item must be defined");
if (ingredients.size() == 1)
return ingredients.get(0);
return new CompoundIngredient(ingredients);
}
if (!json.isJsonObject())
throw new JsonSyntaxException("Expcted ingredient to be a object or array of objects");
JsonObject obj = (JsonObject) json;
String type = GsonHelper.getAsString(obj, "type", "minecraft:item");
if (type.isEmpty())
throw new JsonSyntaxException("Ingredient type can not be an empty string");
IIngredientSerializer<?> serializer = ingredients.get(new ResourceLocation(type));
if (serializer == null)
throw new JsonSyntaxException("Unknown ingredient type: " + type);
return serializer.parse(obj);
}
use of net.minecraft.resources.ResourceLocation in project MinecraftForge by MinecraftForge.
the class ModelProvider method getBuilder.
public T getBuilder(String path) {
Preconditions.checkNotNull(path, "Path must not be null");
ResourceLocation outputLoc = extendWithFolder(path.contains(":") ? new ResourceLocation(path) : new ResourceLocation(modid, path));
this.existingFileHelper.trackGenerated(outputLoc, MODEL);
return generatedModels.computeIfAbsent(outputLoc, factory);
}
Aggregations