Skip to content

Commit

Permalink
- Added LitOnFire Category
Browse files Browse the repository at this point in the history
- Fixed #72
  • Loading branch information
PssbleTrngle committed May 21, 2021
1 parent 51689d2 commit 5d64446
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 38 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,24 @@ Initial 1.16.3 release
- Recipe advancements.

## [3.0.4] - 2021-03-30

### Fixed

- Server not starting due to particle client code loading.

## [3.0.5] - 2021-04-26

### Fixed
- Updated architectury api to fix texture stitch bug

- Updated architectury api to fix texture stitch bug.

## [3.0.6] - 2021-05-21

### Fixed

- Fabric crazed floating (#72)
- JEI Warning when trying to hide an empty list of items

### Added

- LitOnBrazier JEI Category
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static void init() {
);

if (Boolean.parseBoolean(System.getenv("MC_TESTING"))) {
LifecycleEvent.SERVER_STARTED.register(server -> server.halt(false));
LOGGER.info("Detected testing environment, stopping server");
LifecycleEvent.SERVER_STARTED.register(server -> server.halt(true));
}
}

Expand Down
10 changes: 8 additions & 2 deletions common/src/main/java/com/possible_triangle/brazier/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.possible_triangle.brazier.entity.EntityUtil;
import com.possible_triangle.brazier.entity.render.CrazedFlameRenderer;
import com.possible_triangle.brazier.entity.render.CrazedRender;
import com.possible_triangle.brazier.item.HiddenItem;
import com.possible_triangle.brazier.item.LazySpawnEgg;
import com.possible_triangle.brazier.item.LivingTorch;
import com.possible_triangle.brazier.particle.FlameParticle;
Expand Down Expand Up @@ -87,7 +88,10 @@ public class Content {
public static final RegistrySupplier<Block> SPAWN_POWDER = registerBlock("spawn_powder", SpawnPowder::new, p -> p.tab(CreativeModeTab.TAB_MATERIALS));

public static final RegistrySupplier<EntityType<Crazed>> CRAZED = ENTITIES.register("crazed",
() -> EntityUtil.<Crazed>buildType(MobCategory.MONSTER, Crazed::new).fireImmune().build("crazed")
() -> EntityUtil.<Crazed>buildType(MobCategory.MONSTER, Crazed::new)
.size(2F, 0.5F)
.fireImmune()
.build("crazed")
);

public static final RegistrySupplier<LazySpawnEgg> CRAZED_SPAWN_EGG = ITEMS.register("crazed_spawn_egg", () -> new LazySpawnEgg(
Expand All @@ -101,9 +105,11 @@ public class Content {
.size(0.6F, 0.6F)
.fireImmune()
.clientHandler(CrazedFlame::new)
.build("crazed_flame")
.build("crazed_flame")
);

public static final RegistrySupplier<HiddenItem> ICON = ITEMS.register("icon", HiddenItem::new);

public static <T extends Block> RegistrySupplier<T> registerBlock(String name, Supplier<T> supplier, Function<Item.Properties, Item.Properties> props) {
RegistrySupplier<T> block = BLOCKS.register(name, supplier);
ITEMS.register(name, () -> new BlockItem(block.get(), props.apply(new Item.Properties())));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.possible_triangle.brazier.item;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;

public class HiddenItem extends Item {

public HiddenItem() {
super(new Properties().tab(CreativeModeTab.TAB_SEARCH));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "brazier:block/brazier_lit"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

public class EntityUtilImpl {


public static Packet<?> createSpawnPacket(Entity entity, String name) {

CustomEntityNetworking.notifyClients(entity, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
import mezz.jei.api.runtime.IJeiRuntime;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -37,10 +40,10 @@ public void registerRecipes(IRecipeRegistration registration) {
.map(ItemStack::new)
.forEach(item -> registration.addIngredientInfo(item, items, "description.brazier.brazier-1", "description.brazier.brazier-2"));

// Content.LIVING_TORCH.toOptional()
// .map(item -> new LightOnBrazier.Recipe(Ingredient.of(Content.TORCHES), item))
// .map(Collections::singleton)
// .ifPresent(recipes -> registration.addRecipes(recipes, LightOnBrazier.UID));
Content.LIVING_TORCH.toOptional()
.map(item -> new LightOnBrazier.Recipe(Ingredient.of(Content.TORCHES), item))
.map(Collections::singleton)
.ifPresent(recipes -> registration.addRecipes(recipes, LightOnBrazier.UID));

}

Expand All @@ -49,16 +52,24 @@ public void onRuntimeAvailable(IJeiRuntime jei) {
IIngredientManager ingredientManager = jei.getIngredientManager();
IIngredientType<ItemStack> items = ingredientManager.getIngredientType(ItemStack.class);

List<ItemStack> hidden = Conditional.disabled()
.map(ItemStack::new)
.collect(Collectors.toList());
List<ItemStack> hidden = Stream.of(

Conditional.disabled()
.map(ItemStack::new),

Stream.of(Content.ICON)
.filter(RegistrySupplier::isPresent)
.map(RegistrySupplier::get)
.map(ItemStack::new)

).flatMap(Function.identity()).collect(Collectors.toList());

ingredientManager.removeIngredientsAtRuntime(items, hidden);
if (!hidden.isEmpty()) ingredientManager.removeIngredientsAtRuntime(items, hidden);

}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
//registration.addRecipeCategories(new LightOnBrazier(registration.getJeiHelpers().getGuiHelper()));
registration.addRecipeCategories(new LightOnBrazier(registration.getJeiHelpers().getGuiHelper()));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.possible_triangle.brazier.forge.compat.jei;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import com.possible_triangle.brazier.Brazier;
import com.possible_triangle.brazier.Content;
import mezz.jei.api.constants.VanillaTypes;
Expand All @@ -11,26 +9,27 @@
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class LightOnBrazier implements IRecipeCategory<LightOnBrazier.Recipe> {

public static final ResourceLocation UID = new ResourceLocation(Brazier.MOD_ID, "light_on_brazier");
private static List<ItemStack> BRAZIER_LIST = null;

public static List<ItemStack> getBrazier() {
if (BRAZIER_LIST == null) BRAZIER_LIST = Collections.singletonList(new ItemStack(Content.BRAZIER.get()));
return BRAZIER_LIST;
}

private static final int HEIGHT = 32;
private static final int WIDTH = 96;
Expand All @@ -41,16 +40,10 @@ public class LightOnBrazier implements IRecipeCategory<LightOnBrazier.Recipe> {

public LightOnBrazier(IGuiHelper guiHelper) {
this.background = guiHelper.createBlankDrawable(WIDTH, HEIGHT);
this.icon = guiHelper.createDrawableIngredient(new ItemStack(getBrazierBlock()));
this.icon = guiHelper.createDrawableIngredient(new ItemStack(Content.ICON.get()));
this.display = I18n.get("category." + UID.getNamespace() + "." + UID.getPath());
}

private Block getBrazierBlock() {
return Content.BRAZIER.toOptional()
.map(b -> (Block) b)
.orElse(Blocks.SOUL_CAMPFIRE);
}

@Override
public ResourceLocation getUid() {
return UID;
Expand Down Expand Up @@ -79,21 +72,27 @@ public IDrawable getIcon() {
@Override
public void setIngredients(Recipe recipe, IIngredients ingredients) {
List<ItemStack> items = Arrays.asList(recipe.input.getItems());
ingredients.setInputs(VanillaTypes.ITEM, items);
ingredients.setInputLists(VanillaTypes.ITEM, Stream.of(items, getBrazier()).collect(Collectors.toList()));
ingredients.setOutput(VanillaTypes.ITEM, new ItemStack(recipe.output));
}

@Override
public void setRecipe(IRecipeLayout layout, Recipe recipe, IIngredients ingredients) {
layout.getItemStacks().init(0, true, 10, HEIGHT / 2 - 9);
layout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
List<List<ItemStack>> inputs = ingredients.getInputs(VanillaTypes.ITEM);

layout.getItemStacks().init(0, true, WIDTH / 2 - 9, HEIGHT / 2 - 9);
layout.getItemStacks().set(0, new ItemStack(Content.ICON.get()));

layout.getItemStacks().init(1, true, 10, HEIGHT / 2 - 9);
layout.getItemStacks().set(1, inputs.get(0));

layout.getItemStacks().init(1, false, WIDTH - 25, HEIGHT / 2 -9);
layout.getItemStacks().set(1, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
layout.getItemStacks().init(2, false, WIDTH - 25, HEIGHT / 2 - 9);
layout.getItemStacks().set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}

@Override
public void draw(Recipe recipe, PoseStack matrizes, double mouseX, double mouseY) {
/*
matrizes.pushPose();
matrizes.translate(WIDTH / 2F - 9, HEIGHT / 2F - 11, 0);
Expand All @@ -111,6 +110,7 @@ public void draw(Recipe recipe, PoseStack matrizes, double mouseX, double mouseY
renderer.getModelRenderer().renderModel(matrizes.last(), buffer, state, model, 1F, 1F, 1F, 15, 15);
matrizes.popPose();
*/
}

public static class Recipe {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ protected void registerModels() {
.map(ResourceLocation::getPath)
.ifPresent(i -> singleTexture(i, mcLoc("item/generated"), "layer0", modLoc("block/" + i)));


Content.CRAZED_SPAWN_EGG.toOptional()
.map(ForgeRegistryEntry::getRegistryName)
.map(ResourceLocation::getPath)
.ifPresent(i -> withExistingParent(i, mcLoc("item/template_spawn_egg")));

Content.ICON.toOptional()
.map(ForgeRegistryEntry::getRegistryName)
.map(ResourceLocation::getPath)
.ifPresent(i -> withExistingParent(i, modLoc("block/brazier_lit")));

}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ minecraft_version=1.16.5

# Mod
archives_base_name=brazier
mod_version=3.0.5
mod_version=3.0.6
maven_group=com.possible_triangle

# Architectury
Expand Down

0 comments on commit 5d64446

Please sign in to comment.