diff --git a/build.gradle b/build.gradle index bbde7129e..605b20a5e 100644 --- a/build.gradle +++ b/build.gradle @@ -57,8 +57,26 @@ minecraft { } } +repositories { + maven { + // location of the maven that hosts JEI files + name = "Progwml6 maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.k-4u.nl" + } +} + dependencies { minecraft 'net.minecraftforge:forge:1.14.4-28.0.102' + + // compile against the JEI API but do not include it at runtime + compileOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.10:api") + // at runtime, use the full JEI jar + runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.10") } jar { diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index c579bb095..d4e04920a 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -42,6 +42,7 @@ public enum AllItems { __MATERIALS__(), IRON_SHEET(ingredient()), + GOLD_SHEET(ingredient()), ANDESITE_ALLOY_CUBE(ingredient()), BLAZE_BRASS_CUBE(ingredient()), CHORUS_CHROME_CUBE(ingredient(Rarity.UNCOMMON)), diff --git a/src/main/java/com/simibubi/create/AllRecipes.java b/src/main/java/com/simibubi/create/AllRecipes.java index 16cb3af25..f77466f78 100644 --- a/src/main/java/com/simibubi/create/AllRecipes.java +++ b/src/main/java/com/simibubi/create/AllRecipes.java @@ -18,19 +18,10 @@ import net.minecraftforge.event.RegistryEvent; public enum AllRecipes { - PLACEMENT_HANDGUN_UPGRADE(BuilderGunUpgradeRecipe.Serializer::new, IRecipeType.CRAFTING), - - CRUSHING(() -> { - return new ProcessingRecipeSerializer<>(CrushingRecipe::new); - }, Types.CRUSHING), - - SPLASHING(() -> { - return new ProcessingRecipeSerializer<>(SplashingRecipe::new); - }, Types.SPLASHING), - - PRESSING(() -> { - return new ProcessingRecipeSerializer<>(PressingRecipe::new); - }, Types.PRESSING), + PLACEMENT_HANDGUN_UPGRADE(BuilderGunUpgradeRecipe.Serializer::new, Types.BLOCKZAPPER_UPGRADE), + CRUSHING(() -> new ProcessingRecipeSerializer<>(CrushingRecipe::new), Types.CRUSHING), + SPLASHING(() -> new ProcessingRecipeSerializer<>(SplashingRecipe::new), Types.SPLASHING), + PRESSING(() -> new ProcessingRecipeSerializer<>(PressingRecipe::new), Types.PRESSING), ; @@ -38,6 +29,7 @@ public enum AllRecipes { public static IRecipeType CRUSHING = register("crushing"); public static IRecipeType SPLASHING = register("splashing"); public static IRecipeType PRESSING = register("pressing"); + public static IRecipeType BLOCKZAPPER_UPGRADE = register("blockzapper_upgrade"); static > IRecipeType register(final String key) { return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IRecipeType() { diff --git a/src/main/java/com/simibubi/create/ClientEvents.java b/src/main/java/com/simibubi/create/ClientEvents.java index 66c95f5ea..07e0ed649 100644 --- a/src/main/java/com/simibubi/create/ClientEvents.java +++ b/src/main/java/com/simibubi/create/ClientEvents.java @@ -3,6 +3,7 @@ package com.simibubi.create; import java.util.ArrayList; import java.util.List; +import com.simibubi.create.compat.jei.AnimatedKinetics; import com.simibubi.create.foundation.block.IBlockWithScrollableValue; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.utility.TooltipHelper; @@ -36,6 +37,9 @@ public class ClientEvents { public static void onTick(ClientTickEvent event) { if (event.phase == Phase.START) return; + + AnimatedKinetics.tick(); + if (!isGameActive()) return; diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenResources.java b/src/main/java/com/simibubi/create/ScreenResources.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/gui/ScreenResources.java rename to src/main/java/com/simibubi/create/ScreenResources.java index c65cc285a..a62fbedc1 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenResources.java +++ b/src/main/java/com/simibubi/create/ScreenResources.java @@ -1,6 +1,4 @@ -package com.simibubi.create.foundation.gui; - -import com.simibubi.create.Create; +package com.simibubi.create; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; @@ -34,6 +32,12 @@ public enum ScreenResources { STOCKSWITCH_BOUND_LEFT("flex_crate_and_stockpile_switch.png", 234, 129, 7, 21), STOCKSWITCH_BOUND_RIGHT("flex_crate_and_stockpile_switch.png", 241, 129, 7, 21), + // JEI + CRUSHING_RECIPE("recipes1.png", 177, 109), + FAN_RECIPE("recipes1.png", 0, 128, 177, 109), + BLOCKZAPPER_UPGRADE_RECIPE("recipes2.png", 144, 66), + PRESSER_RECIPE("recipes2.png", 0, 108, 177, 109), + // Widgets PALETTE_BUTTON("palette_picker.png", 0, 236, 20, 20), TEXT_INPUT("widgets.png", 0, 28, 194, 47), diff --git a/src/main/java/com/simibubi/create/compat/jei/AnimatedCrushingWheels.java b/src/main/java/com/simibubi/create/compat/jei/AnimatedCrushingWheels.java new file mode 100644 index 000000000..6145c3c3d --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/AnimatedCrushingWheels.java @@ -0,0 +1,58 @@ +package com.simibubi.create.compat.jei; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; + +import net.minecraft.block.BlockState; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction.Axis; + +public class AnimatedCrushingWheels extends AnimatedKinetics { + + @Override + public int getWidth() { + return 150; + } + + @Override + public int getHeight() { + return 100; + } + + @Override + public void draw(int xOffset, int yOffset) { + GlStateManager.enableDepthTest(); + GlStateManager.translatef(xOffset, yOffset, 0); + GlStateManager.translatef(-45, 10, 0); + GlStateManager.rotatef(22.5f, 0, 1, 0); + GlStateManager.scaled(.45f, .45f, .45f); + ScreenElementRenderer.renderBlock(this::leftWheel); + ScreenElementRenderer.renderBlock(this::rightWheel); + } + + private BlockState leftWheel() { + float angle = getCurrentAngle(); + GlStateManager.translatef(-50, 0, 0); + + float t = 25; + GlStateManager.translatef(t, -t, t); + GlStateManager.rotated(angle, 0, 0, 1); + GlStateManager.translatef(-t, t, -t); + + return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + } + + private BlockState rightWheel() { + float angle = -getCurrentAngle(); + GlStateManager.translatef(50, 0, 0); + + float t = 25; + GlStateManager.translatef(t, -t, t); + GlStateManager.rotated(angle, 0, 0, 1); + GlStateManager.translatef(-t, t, -t); + + return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/AnimatedKinetics.java new file mode 100644 index 000000000..59571a2a9 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/AnimatedKinetics.java @@ -0,0 +1,18 @@ +package com.simibubi.create.compat.jei; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.client.Minecraft; + +public abstract class AnimatedKinetics implements IDrawable { + + protected static int ticks; + + public static void tick() { + ticks++; + } + + public static float getCurrentAngle() { + return ((ticks + Minecraft.getInstance().getRenderPartialTicks()) * 4f) % 360; + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/AnimatedPress.java b/src/main/java/com/simibubi/create/compat/jei/AnimatedPress.java new file mode 100644 index 000000000..55fee1255 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/AnimatedPress.java @@ -0,0 +1,81 @@ +package com.simibubi.create.compat.jei; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; + +import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; + +public class AnimatedPress extends AnimatedKinetics { + + @Override + public int getWidth() { + return 50; + } + + @Override + public int getHeight() { + return 100; + } + + @Override + public void draw(int xOffset, int yOffset) { + GlStateManager.pushMatrix(); + GlStateManager.enableDepthTest(); + GlStateManager.translatef(xOffset, yOffset, 0); + GlStateManager.rotatef(-15.5f, 1, 0, 0); + GlStateManager.rotatef(22.5f, 0, 1, 0); + GlStateManager.translatef(-45, -5, 0); + GlStateManager.scaled(.45f, .45f, .45f); + + GlStateManager.pushMatrix(); + ScreenElementRenderer.renderBlock(this::shaft); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + ScreenElementRenderer.renderBlock(this::body); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + ScreenElementRenderer.renderBlock(this::head); + GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); + } + + private BlockState shaft() { + float t = 25; + GlStateManager.translatef(t, -t, t); + GlStateManager.rotated(getCurrentAngle() * 2, 0, 0, 1); + GlStateManager.translatef(-t, t, -t); + return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + } + + private BlockState body() { + return AllBlocks.MECHANICAL_PRESS.get().getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, + Direction.EAST); + } + + private BlockState head() { + float cycle = (ticks + Minecraft.getInstance().getRenderPartialTicks()) % 30; + float verticalOffset = 0; + if (cycle < 10) { + float progress = cycle / 10; + verticalOffset = -(progress * progress * progress); + } else if (cycle < 15) { + verticalOffset = -1; + } else if (cycle < 20) { + verticalOffset = -1 + (1 - ((20 - cycle) / 5)); + } else { + verticalOffset = 0; + } + GlStateManager.translated(0, -verticalOffset * 50, 0); + return AllBlocks.MECHANICAL_PRESS_HEAD.get().getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, + Direction.EAST); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/BlastingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/BlastingViaFanCategory.java new file mode 100644 index 000000000..d1fd3164d --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/BlastingViaFanCategory.java @@ -0,0 +1,83 @@ +package com.simibubi.create.compat.jei; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.utility.Lang; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.crafting.AbstractCookingRecipe; +import net.minecraft.util.ResourceLocation; + +public class BlastingViaFanCategory extends ProcessingViaFanCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "blasting_via_fan"); + private IDrawable icon; + + public BlastingViaFanCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), + () -> new ItemStack(Items.LAVA_BUCKET)); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return AbstractCookingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.blastingViaFan"); + } + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(ScreenResources.FAN_RECIPE); + } + + @Override + public void renderAttachedBlock() { + BlockState state = Blocks.LAVA.getDefaultState().with(FlowingFluidBlock.LEVEL, 8); + // This is stupid + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 0, 200); + GlStateManager.enableRescaleNormal(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 200, 0); + GlStateManager.rotated(90, 1, 0, 0); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 200, 0); + GlStateManager.rotated(90, 1, 0, 0); + GlStateManager.rotated(270, 0, 0, 1); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(-103, -100, 0); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java b/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java new file mode 100644 index 000000000..a0516c980 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/BlockzapperUpgradeCategory.java @@ -0,0 +1,126 @@ +package com.simibubi.create.compat.jei; + +import static com.simibubi.create.ScreenResources.BLOCKZAPPER_UPGRADE_RECIPE; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunUpgradeRecipe; + +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; + +public class BlockzapperUpgradeCategory implements IRecipeCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "blockzapper_upgrade"); + private IDrawable icon; + + public BlockzapperUpgradeCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PLACEMENT_HANDGUN.get()), + () -> ItemStack.EMPTY); // replace with uparrow when available + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return BuilderGunUpgradeRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.blockzapperUpgrade"); + } + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(BLOCKZAPPER_UPGRADE_RECIPE); + } + + @Override + public void setIngredients(BuilderGunUpgradeRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, BuilderGunUpgradeRecipe recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + ShapedRecipe shape = recipe.getRecipe(); + NonNullList shapedIngredients = shape.getIngredients(); + + int top = 0; + int left = 0; + + int i = 0; + for (int y = 0; y < shape.getRecipeHeight(); y++) { + for (int x = 0; x < shape.getRecipeWidth(); x++) { + itemStacks.init(i, true, left + x * 18, top + y * 18); + itemStacks.set(i, Arrays.asList(shapedIngredients.get(i).getMatchingStacks())); + i++; + } + } +// itemStacks.init(9, false, BLOCKZAPPER_UPGRADE_RECIPE.width / 2 - 9, BLOCKZAPPER_UPGRADE_RECIPE.height - 18 - 10); +// itemStacks.set(9, recipe.getRecipeOutput()); + } + + @Override + public List getTooltipStrings(BuilderGunUpgradeRecipe recipe, double mouseX, double mouseY) { + List list = new ArrayList<>(); + if (mouseX < 91 || mouseX > 91 + 52 || mouseY < 1 || mouseY > 53) + return list; + list.addAll(recipe.getRecipeOutput() + .getTooltip(Minecraft.getInstance().player, + Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED + : ITooltipFlag.TooltipFlags.NORMAL) + .stream().map(ITextComponent::getFormattedText).collect(Collectors.toList())); + return list; + } + + @Override + public void draw(BuilderGunUpgradeRecipe recipe, double mouseX, double mouseY) { + FontRenderer font = Minecraft.getInstance().fontRenderer; + String componentName = Lang + .translate("blockzapper.component." + recipe.getUpgradedComponent().name().toLowerCase()); + String text = "+ " + recipe.getTier().color + componentName; + font.drawStringWithShadow(text, + (BLOCKZAPPER_UPGRADE_RECIPE.width - font.getStringWidth(text)) / 2, 57, 0x8B8B8B); + + GlStateManager.pushMatrix(); + GlStateManager.translated(126, 0, 0); + GlStateManager.scaled(3.5, 3.5, 3.5); + GlStateManager.translated(-10, 0, 0); + GlStateManager.color3f(1, 1, 1); + GlStateManager.enableDepthTest(); + ScreenElementRenderer.render3DItem(() -> recipe.getRecipeOutput()); + GlStateManager.popMatrix(); + } +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java new file mode 100644 index 000000000..084157341 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -0,0 +1,117 @@ +package com.simibubi.create.compat.jei; + +import java.util.List; +import java.util.stream.Collectors; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllItems; +import com.simibubi.create.AllRecipes; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.utility.Lang; + +import mezz.jei.api.IModPlugin; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.registration.IRecipeCatalystRegistration; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; +import mezz.jei.api.registration.ISubtypeRegistration; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; + +@JeiPlugin +public class CreateJEI implements IModPlugin { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "jei_plugin"); + private CrushingCategory crushingCategory; + private SplashingCategory splashingCategory; + private SmokingViaFanCategory smokingCategory; + private PressingCategory pressingCategory; + private BlastingViaFanCategory blastingCategory; + private BlockzapperUpgradeCategory blockzapperCategory; + + @Override + public ResourceLocation getPluginUid() { + return ID; + } + + public CreateJEI() { + crushingCategory = new CrushingCategory(); + splashingCategory = new SplashingCategory(); + pressingCategory = new PressingCategory(); + smokingCategory = new SmokingViaFanCategory(); + blastingCategory = new BlastingViaFanCategory(); + blockzapperCategory = new BlockzapperUpgradeCategory(); + } + + @Override + public void registerItemSubtypes(ISubtypeRegistration registration) { + registration.useNbtForSubtypes(AllItems.PLACEMENT_HANDGUN.item); + } + + @Override + public void registerCategories(IRecipeCategoryRegistration registration) { + registration.addRecipeCategories(crushingCategory, splashingCategory, pressingCategory, smokingCategory, + blastingCategory, blockzapperCategory); + } + + @Override + public void registerRecipes(IRecipeRegistration registration) { + registration.addRecipes(findRecipes(AllRecipes.CRUSHING), crushingCategory.getUid()); + registration.addRecipes(findRecipes(AllRecipes.SPLASHING), splashingCategory.getUid()); + registration.addRecipes(findRecipes(AllRecipes.PRESSING), pressingCategory.getUid()); + registration.addRecipes(findRecipes(AllRecipes.PLACEMENT_HANDGUN_UPGRADE), blockzapperCategory.getUid()); + registration.addRecipes(findRecipesByType(IRecipeType.SMOKING), smokingCategory.getUid()); + registration.addRecipes(findRecipesByTypeExcluding(IRecipeType.SMELTING, IRecipeType.SMOKING), + blastingCategory.getUid()); + } + + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { + ItemStack fan = new ItemStack(AllBlocks.ENCASED_FAN.get()); + + ItemStack splashingFan = fan.copy() + .setDisplayName(new StringTextComponent(TextFormatting.RESET + Lang.translate("recipe.splashing.fan"))); + ItemStack smokingFan = fan.copy().setDisplayName( + new StringTextComponent(TextFormatting.RESET + Lang.translate("recipe.smokingViaFan.fan"))); + ItemStack blastingFan = fan.copy().setDisplayName( + new StringTextComponent(TextFormatting.RESET + Lang.translate("recipe.blastingViaFan.fan"))); + + registration.addRecipeCatalyst(new ItemStack(AllBlocks.CRUSHING_WHEEL.get()), crushingCategory.getUid()); + registration.addRecipeCatalyst(splashingFan, splashingCategory.getUid()); + registration.addRecipeCatalyst(smokingFan, smokingCategory.getUid()); + registration.addRecipeCatalyst(blastingFan, blastingCategory.getUid()); + registration.addRecipeCatalyst(new ItemStack(AllBlocks.MECHANICAL_PRESS.get()), pressingCategory.getUid()); + registration.addRecipeCatalyst(new ItemStack(AllItems.PLACEMENT_HANDGUN.get()), blockzapperCategory.getUid()); + } + + private static List> findRecipes(AllRecipes recipe) { + return findRecipesByType(recipe.type); + } + + private static List> findRecipesByType(IRecipeType type) { + return Minecraft.getInstance().world.getRecipeManager().getRecipes().stream().filter(r -> r.getType() == type) + .collect(Collectors.toList()); + } + + private static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType excludingType) { + List> byType = findRecipesByType(type); + List> byExcludingType = findRecipesByType(excludingType); + byType.removeIf(recipe -> { + for (IRecipe r : byExcludingType) { + ItemStack[] matchingStacks = recipe.getIngredients().get(0).getMatchingStacks(); + if (matchingStacks.length == 0) + return true; + if (r.getIngredients().get(0).test(matchingStacks[0])) + return true; + } + return false; + }); + return byType; + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/CrushingCategory.java b/src/main/java/com/simibubi/create/compat/jei/CrushingCategory.java new file mode 100644 index 000000000..27d8eb0b3 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/CrushingCategory.java @@ -0,0 +1,93 @@ +package com.simibubi.create.compat.jei; + +import java.util.Arrays; +import java.util.List; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.base.StochasticOutput; +import com.simibubi.create.modules.contraptions.receivers.CrushingRecipe; + +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextFormatting; + +public class CrushingCategory implements IRecipeCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "crushing"); + private AnimatedCrushingWheels crushingWheels = new AnimatedCrushingWheels(); + private IDrawable icon; + + public CrushingCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.CRUSHING_WHEEL.get()), + () -> new ItemStack(AllItems.FLOUR.get())); + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return CrushingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.crushing"); + } + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(ScreenResources.CRUSHING_RECIPE); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public void setIngredients(CrushingRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutputs(VanillaTypes.ITEM, recipe.getPossibleOutputs()); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, CrushingRecipe recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, true, 60, 2); + itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + + List results = recipe.getRollableResults(); + for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { + itemStacks.init(outputIndex + 1, false, 60 + 18 * outputIndex, 78); + itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack()); + } + + itemStacks.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> { + if (input) + return; + StochasticOutput output = results.get(slotIndex - 1); + if (output.getChance() != 1) + tooltip.add(1, TextFormatting.GOLD + + Lang.translate("recipe.processing.chance", (int) (output.getChance() * 100))); + }); + } + + @Override + public void draw(CrushingRecipe recipe, double mouseX, double mouseY) { + crushingWheels.draw(100, 47); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java new file mode 100644 index 000000000..b1bc80078 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/DoubleItemIcon.java @@ -0,0 +1,61 @@ +package com.simibubi.create.compat.jei; + +import java.util.function.Supplier; + +import com.mojang.blaze3d.platform.GlStateManager; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.item.ItemStack; + +public class DoubleItemIcon implements IDrawable { + + private Supplier primarySupplier; + private Supplier secondarySupplier; + private ItemStack primaryStack; + private ItemStack secondaryStack; + + public DoubleItemIcon(Supplier primary, Supplier secondary) { + this.primarySupplier = primary; + this.secondarySupplier = secondary; + } + + @Override + public int getWidth() { + return 18; + } + + @Override + public int getHeight() { + return 18; + } + + @Override + public void draw(int xOffset, int yOffset) { + if (primaryStack == null) { + primaryStack = primarySupplier.get(); + secondaryStack = secondarySupplier.get(); + } + + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.color4f(1, 1, 1, 1); + GlStateManager.enableDepthTest(); + GlStateManager.pushMatrix(); + GlStateManager.translated(xOffset, yOffset, 0); + + GlStateManager.pushMatrix(); + GlStateManager.translated(1, 1, 0); + Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(primaryStack, 0, 0); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(10, 10, 100); + GlStateManager.scaled(.5, .5, .5); + Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(secondaryStack, 0, 0); + GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/PressingCategory.java b/src/main/java/com/simibubi/create/compat/jei/PressingCategory.java new file mode 100644 index 000000000..d4cc98ead --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/PressingCategory.java @@ -0,0 +1,85 @@ +package com.simibubi.create.compat.jei; + +import java.util.Arrays; +import java.util.List; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.base.StochasticOutput; +import com.simibubi.create.modules.contraptions.receivers.PressingRecipe; + +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +public class PressingCategory implements IRecipeCategory { + + private AnimatedPress press; + private static ResourceLocation ID = new ResourceLocation(Create.ID, "pressing"); + private IDrawable icon; + + public PressingCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.MECHANICAL_PRESS.get()), + () -> new ItemStack(AllItems.IRON_SHEET.get())); + press = new AnimatedPress(); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return PressingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.pressing"); + } + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(ScreenResources.PRESSER_RECIPE); + } + + @Override + public void setIngredients(PressingRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutputs(VanillaTypes.ITEM, recipe.getPossibleOutputs()); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, PressingRecipe recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, true, 27, 60); + itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + + List results = recipe.getRollableResults(); + for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { + itemStacks.init(outputIndex + 1, false, 113 + 19 * outputIndex, 60); + itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack()); + } + } + + @Override + public void draw(PressingRecipe recipe, double mouseX, double mouseY) { + press.draw(ScreenResources.PRESSER_RECIPE.width / 2, 30); + + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/ProcessingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/ProcessingViaFanCategory.java new file mode 100644 index 000000000..8711e518c --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/ProcessingViaFanCategory.java @@ -0,0 +1,85 @@ +package com.simibubi.create.compat.jei; + +import java.util.Arrays; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; + +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.block.BlockState; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction.Axis; + +public abstract class ProcessingViaFanCategory> implements IRecipeCategory { + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(ScreenResources.FAN_RECIPE); + } + + @Override + public void setIngredients(T recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput()); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, T recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, true, 20, 67); + itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + + itemStacks.init(1, false, 139, 67); + itemStacks.set(1, recipe.getRecipeOutput()); + } + + @Override + public void draw(T recipe, double mouseX, double mouseY) { + GlStateManager.pushMatrix(); + GlStateManager.color3f(1, 1, 1); + GlStateManager.enableDepthTest(); + + GlStateManager.translated(28, 42, 0); + GlStateManager.rotated(10.5, -1f, 0, 0); + GlStateManager.rotated(15.5, 0, 1, 0); + GlStateManager.scaled(.6f, .6f, .6f); + ScreenElementRenderer.renderBlock(this::renderFanCasing); + + GlStateManager.pushMatrix(); + float angle = AnimatedKinetics.getCurrentAngle() * 12; + float t = 25; + GlStateManager.translatef(t, -t, t); + GlStateManager.rotated(angle, 0, 0, 1); + GlStateManager.translatef(-t, t, -t); + ScreenElementRenderer.renderBlock(this::renderFanInner); + GlStateManager.popMatrix(); + + GlStateManager.translated(-10, 0, 95); + GlStateManager.rotated(7, 0, 1, 0); + renderAttachedBlock(); + + GlStateManager.popMatrix(); + + } + + protected BlockState renderFanCasing() { + + return AllBlocks.ENCASED_FAN.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + } + + protected BlockState renderFanInner() { + + return AllBlocks.ENCASED_FAN_INNER.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + } + + public abstract void renderAttachedBlock(); + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java b/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java new file mode 100644 index 000000000..e6f9f3526 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/ScreenResourceWrapper.java @@ -0,0 +1,33 @@ +package com.simibubi.create.compat.jei; + +import com.simibubi.create.ScreenResources; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.client.gui.AbstractGui; + +public class ScreenResourceWrapper implements IDrawable { + + private ScreenResources resource; + + public ScreenResourceWrapper(ScreenResources resource) { + this.resource = resource; + } + + @Override + public int getWidth() { + return resource.width; + } + + @Override + public int getHeight() { + return resource.height; + } + + @Override + public void draw(int xOffset, int yOffset) { + resource.bind(); + AbstractGui.blit(xOffset, yOffset, 0, resource.startX, resource.startY, resource.width, resource.height, 256, + 256); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/SmokingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/SmokingViaFanCategory.java new file mode 100644 index 000000000..d81083c57 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/SmokingViaFanCategory.java @@ -0,0 +1,49 @@ +package com.simibubi.create.compat.jei; + +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.utility.Lang; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.block.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.crafting.SmokingRecipe; +import net.minecraft.util.ResourceLocation; + +public class SmokingViaFanCategory extends ProcessingViaFanCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "smoking_via_fan"); + private IDrawable icon; + + public SmokingViaFanCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), + () -> new ItemStack(Items.BLAZE_POWDER)); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return SmokingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.smokingViaFan"); + } + + @Override + public void renderAttachedBlock() { + ScreenElementRenderer.renderBlock(() -> Blocks.FIRE.getDefaultState()); + } +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/compat/jei/SplashingCategory.java b/src/main/java/com/simibubi/create/compat/jei/SplashingCategory.java new file mode 100644 index 000000000..24eb86065 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/SplashingCategory.java @@ -0,0 +1,82 @@ +package com.simibubi.create.compat.jei; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.receivers.SplashingRecipe; + +import mezz.jei.api.gui.drawable.IDrawable; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.ResourceLocation; + +public class SplashingCategory extends ProcessingViaFanCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "splashing"); + private IDrawable icon; + + public SplashingCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()), + () -> new ItemStack(Items.WATER_BUCKET)); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return SplashingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.splashing"); + } + + @Override + public IDrawable getBackground() { + return new ScreenResourceWrapper(ScreenResources.FAN_RECIPE); + } + + @Override + public void renderAttachedBlock() { + BlockState state = Blocks.WATER.getDefaultState().with(FlowingFluidBlock.LEVEL, 8); + // This is stupid + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 0, 200); + + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 200, 0); + GlStateManager.rotated(90, 1, 0, 0); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(0, 200, 0); + GlStateManager.rotated(90, 1, 0, 0); + GlStateManager.rotated(270, 0, 0, 1); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + GlStateManager.translated(-103, -100, 0); + ScreenElementRenderer.renderBlock(() -> state); + GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java index f622f5739..db6dad85a 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java @@ -2,13 +2,19 @@ package com.simibubi.create.foundation.gui; import java.util.function.Supplier; +import org.lwjgl.opengl.GL11; + import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; public class ScreenElementRenderer { @@ -46,6 +52,17 @@ public class ScreenElementRenderer { mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); mc.getBlockRendererDispatcher().renderBlockBrightness(toRender, 1); + if (!toRender.getFluidState().isEmpty()) { + RenderHelper.disableStandardItemLighting(); + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferbuilder = tessellator.getBuffer(); + bufferbuilder.setTranslation(0, -300, 0); + bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + mc.getBlockRendererDispatcher().renderFluid(new BlockPos(0, 300, 0), mc.world, bufferbuilder, toRender.getFluidState()); + Tessellator.getInstance().draw(); + bufferbuilder.setTranslation(0, 0, 0); + } + GlStateManager.disableAlphaTest(); GlStateManager.disableRescaleNormal(); diff --git a/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java b/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java index 934cea3d7..ea0e9d294 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java @@ -4,6 +4,7 @@ import java.util.function.Consumer; import org.lwjgl.glfw.GLFW; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.gui.widget.TextFieldWidget; diff --git a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java index 441ccd322..8d16c4312 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ToolSelectionScreen.java @@ -5,6 +5,7 @@ import java.util.function.Consumer; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllKeys; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.schematics.client.tools.Tools; diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java index 8e716cbd7..78b27b044 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/IconButton.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.gui.widgets; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.foundation.gui.ScreenResources; +import com.simibubi.create.ScreenResources; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java index c8a42ef42..e1b41c2b3 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/Indicator.java @@ -1,7 +1,7 @@ package com.simibubi.create.foundation.gui.widgets; import com.google.common.collect.ImmutableList; -import com.simibubi.create.foundation.gui.ScreenResources; +import com.simibubi.create.ScreenResources; public class Indicator extends AbstractSimiWidget { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipe.java b/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipe.java index 66d83ad50..0d552fa13 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipe.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipe.java @@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.base; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import com.simibubi.create.AllRecipes; @@ -16,15 +17,15 @@ import net.minecraft.util.ResourceLocation; public abstract class ProcessingRecipe implements IRecipe { protected final List ingredients; - protected final List results; + private final List results; private final IRecipeType type; private final IRecipeSerializer serializer; protected final ResourceLocation id; protected final String group; protected final int processingDuration; - public ProcessingRecipe(AllRecipes recipeType, ResourceLocation id, String group, - List ingredients, List results, int processingDuration) { + public ProcessingRecipe(AllRecipes recipeType, ResourceLocation id, String group, List ingredients, + List results, int processingDuration) { this.type = recipeType.type; this.serializer = recipeType.serializer; this.id = id; @@ -40,18 +41,14 @@ public abstract class ProcessingRecipe implements IRecipe< nonnulllist.addAll(this.ingredients); return nonnulllist; } - + public int getProcessingDuration() { return processingDuration; } - - public List getAllResults() { - return results; - } - + public List rollResults() { List stacks = new ArrayList<>(); - for (StochasticOutput output : results) { + for (StochasticOutput output : getRollableResults()) { ItemStack stack = output.rollOutput(); if (!stack.isEmpty()) stacks.add(stack); @@ -71,7 +68,7 @@ public abstract class ProcessingRecipe implements IRecipe< @Override public ItemStack getRecipeOutput() { - return results.isEmpty() ? ItemStack.EMPTY : results.get(0).getStack(); + return getRollableResults().isEmpty() ? ItemStack.EMPTY : getRollableResults().get(0).getStack(); } @Override @@ -83,7 +80,7 @@ public abstract class ProcessingRecipe implements IRecipe< public IRecipeSerializer getSerializer() { return serializer; } - + @Override public String getGroup() { return group; @@ -93,4 +90,12 @@ public abstract class ProcessingRecipe implements IRecipe< public IRecipeType getType() { return type; } + + public List getRollableResults() { + return results; + } + + public List getPossibleOutputs() { + return getRollableResults().stream().map(output -> output.getStack()).collect(Collectors.toList()); + } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipeSerializer.java b/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipeSerializer.java index 2df6a9bf9..d6cc2e9c8 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipeSerializer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/ProcessingRecipeSerializer.java @@ -70,8 +70,8 @@ public class ProcessingRecipeSerializer> buffer.writeInt(recipe.ingredients.size()); recipe.ingredients.forEach(i -> i.write(buffer)); - buffer.writeInt(recipe.results.size()); - recipe.results.forEach(i -> i.write(buffer)); + buffer.writeInt(recipe.getRollableResults().size()); + recipe.getRollableResults().forEach(i -> i.write(buffer)); buffer.writeInt(recipe.processingDuration); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java index 182644828..fdd23d59d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java @@ -7,6 +7,7 @@ import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; import net.minecraft.util.Rotation; public abstract class RotatedPillarKineticBlock extends KineticBlock { @@ -35,6 +36,24 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { return state; } } + + public Axis getPreferredAxis(BlockItemUseContext context) { + Axis prefferedAxis = null; + for (Direction side : Direction.values()) { + BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); + if (blockState.getBlock() instanceof IRotate) { + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side), + blockState, side.getOpposite())) + if (prefferedAxis != null && prefferedAxis != side.getAxis()) { + prefferedAxis = null; + break; + } else { + prefferedAxis = side.getAxis(); + } + } + } + return prefferedAxis; + } @Override protected void fillStateContainer(StateContainer.Builder builder) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/generators/MotorBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/generators/MotorBlock.java index faffc09a4..6e0d0074e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/generators/MotorBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/generators/MotorBlock.java @@ -7,6 +7,7 @@ import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; @@ -40,6 +41,14 @@ public class MotorBlock extends HorizontalKineticBlock return new MotorTileEntity(); } + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + Direction preferred = getPreferredHorizontalFacing(context); + if (context.isPlacerSneaking() || preferred == null) + return super.getStateForPlacement(context); + return getDefaultState().with(HORIZONTAL_FACING, preferred); + } + // IRotate: @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/receivers/EncasedFanBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/receivers/EncasedFanBlock.java index ea253fccd..089a2cfae 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/receivers/EncasedFanBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/receivers/EncasedFanBlock.java @@ -1,13 +1,16 @@ package com.simibubi.create.modules.contraptions.receivers; +import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.modules.contraptions.relays.EncasedShaftBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; @@ -29,13 +32,27 @@ public class EncasedFanBlock extends EncasedShaftBlock implements IWithTileEntit public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { notifyFanTile(worldIn, pos); - + if (worldIn.isRemote || state.get(AXIS).isHorizontal()) return; - + withTileEntityDo(worldIn, pos, EncasedFanTileEntity::updateGenerator); } - + + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + if (context.isPlacerSneaking()) + return super.getStateForPlacement(context); + BlockState blockState = context.getWorld() + .getBlockState(context.getPos().offset(context.getFace().getOpposite())); + if (AllBlocks.ENCASED_FAN.typeOf(blockState)) + return getDefaultState().with(AXIS, blockState.get(AXIS)); + Axis preferred = getPreferredAxis(context); + if (preferred != null) + return getDefaultState().with(AXIS, preferred); + return super.getStateForPlacement(context); + } + protected void notifyFanTile(IWorld world, BlockPos pos) { withTileEntityDo(world, pos, EncasedFanTileEntity::updateFrontBlock); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java index 2ced37da1..32fc8531d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/receivers/constructs/MechanicalPistonBlock.java @@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateConfig; +import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.KineticBlock; import net.minecraft.block.Block; @@ -19,7 +20,6 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; @@ -63,13 +63,48 @@ public class MechanicalPistonBlock extends KineticBlock { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction facing = context.getNearestLookingDirection().getOpposite(); + BlockPos pos = context.getPos(); + World world = context.getWorld(); + boolean alongFirst = false; if (context.isPlacerSneaking()) facing = facing.getOpposite(); - Vec3d diff = context.getHitVec().subtract(new Vec3d(context.getPos())); - double firstCoord = facing.getAxis() == Axis.X ? diff.y : diff.x; - double secondCoord = facing.getAxis() == Axis.Z ? diff.y : diff.z; - boolean alongFirst = firstCoord + secondCoord < 1 ^ firstCoord < secondCoord; + if (facing.getAxis().isHorizontal()) { + alongFirst = facing.getAxis() == Axis.Z; + + Block blockAbove = world.getBlockState(pos.offset(Direction.UP)).getBlock(); + boolean shaftAbove = blockAbove instanceof IRotate && ((IRotate) blockAbove).hasShaftTowards(world, + pos.up(), world.getBlockState(pos.up()), Direction.DOWN); + Block blockBelow = world.getBlockState(pos.offset(Direction.DOWN)).getBlock(); + boolean shaftBelow = blockBelow instanceof IRotate && ((IRotate) blockBelow).hasShaftTowards(world, + pos.down(), world.getBlockState(pos.down()), Direction.UP); + + if (shaftAbove || shaftBelow) + alongFirst = facing.getAxis() == Axis.X; + } + + if (facing.getAxis().isVertical()) { + alongFirst = context.getPlacementHorizontalFacing().getAxis() == Axis.X; + Direction prefferedSide = null; + for (Direction side : Direction.values()) { + if (side.getAxis().isVertical()) + continue; + BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); + if (blockState.getBlock() instanceof IRotate) { + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), + context.getPos().offset(side), blockState, side.getOpposite())) + if (prefferedSide != null && prefferedSide.getAxis() != side.getAxis()) { + prefferedSide = null; + break; + } else { + prefferedSide = side; + } + } + } + if (prefferedSide != null) { + alongFirst = prefferedSide.getAxis() == Axis.X; + } + } return this.getDefaultState().with(FACING, facing).with(STATE, PistonState.RETRACTED) .with(AXIS_ALONG_FIRST_COORDINATE, alongFirst); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/EncasedShaftBlock.java index 9301eb08f..48a0976a4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/EncasedShaftBlock.java @@ -38,7 +38,9 @@ public class EncasedShaftBlock extends RotatedPillarKineticBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { if (context.isPlacerSneaking()) return super.getStateForPlacement(context); - return this.getDefaultState().with(AXIS, context.getNearestLookingDirection().getAxis()); + Axis preferredAxis = getPreferredAxis(context); + return this.getDefaultState().with(AXIS, + preferredAxis == null ? context.getNearestLookingDirection().getAxis() : preferredAxis); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/GearboxBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/GearboxBlock.java index 2abc89192..8e561381a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/GearboxBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/GearboxBlock.java @@ -1,12 +1,16 @@ package com.simibubi.create.modules.contraptions.relays; +import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.PushReaction; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; @@ -27,6 +31,52 @@ public class GearboxBlock extends RotatedPillarKineticBlock { return PushReaction.PUSH_ONLY; } + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + BlockState placedOnState = context.getWorld() + .getBlockState(context.getPos().offset(context.getFace().getOpposite())); + Block placedOn = placedOnState.getBlock(); + + if (!(placedOn instanceof IRotate) || !((IRotate) placedOn).hasShaftTowards(context.getWorld(), + context.getPos(), placedOnState, context.getFace())) + return getDefaultState().with(AXIS, context.getFace().getAxis()); + + Axis badAxis = context.getFace().getAxis(); + Axis otherBadAxis = null; + + for (Direction side : Direction.values()) { + if (side.getAxis() == badAxis) + continue; + + BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(side)); + if (blockState.getBlock() instanceof IRotate) { + if (((IRotate) blockState.getBlock()).hasShaftTowards(context.getWorld(), context.getPos().offset(side), + blockState, side.getOpposite())) + if (otherBadAxis != null && otherBadAxis != side.getAxis()) { + otherBadAxis = null; + break; + } else { + otherBadAxis = side.getAxis(); + } + } + } + + boolean skipped = false; + for (Axis axis : Axis.values()) { + if (axis == badAxis) + continue; + if (!skipped && context.isPlacerSneaking() && (otherBadAxis == null || badAxis == null)) { + skipped = true; + continue; + } + if (axis == otherBadAxis) + continue; + return getDefaultState().with(AXIS, axis); + } + + return super.getStateForPlacement(context); + } + // IRotate: @Override diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java index 8c4831f24..5ce44020e 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunItem.java @@ -72,7 +72,7 @@ public class BuilderGunItem extends Item { ; - protected TextFormatting color; + public TextFormatting color; private ComponentTier(TextFormatting color) { this.color = color; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunScreen.java index 0aeb49d81..d0dfc3a4a 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunScreen.java @@ -7,8 +7,8 @@ import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllPackets; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.Indicator; import com.simibubi.create.foundation.gui.widgets.Indicator.State; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java index 0efa2b4f0..6f8cbf309 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/BuilderGunUpgradeRecipe.java @@ -10,6 +10,7 @@ import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.item.crafting.IRecipeSerializer; +import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; @@ -31,7 +32,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { @Override public boolean matches(CraftingInventory inv, World worldIn) { - return recipe.matches(inv, worldIn); + return getRecipe().matches(inv, worldIn); } @Override @@ -40,7 +41,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { ItemStack handgun = inv.getStackInSlot(slot).copy(); if (!AllItems.PLACEMENT_HANDGUN.typeOf(handgun)) continue; - BuilderGunItem.setTier(component, tier, handgun); + BuilderGunItem.setTier(getUpgradedComponent(), getTier(), handgun); return handgun; } return ItemStack.EMPTY; @@ -49,7 +50,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { @Override public ItemStack getRecipeOutput() { ItemStack handgun = new ItemStack(AllItems.PLACEMENT_HANDGUN.get()); - BuilderGunItem.setTier(component, tier, handgun); + BuilderGunItem.setTier(getUpgradedComponent(), getTier(), handgun); return handgun; } @@ -60,9 +61,14 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { @Override public ResourceLocation getId() { - return recipe.getId(); + return getRecipe().getId(); } + @Override + public IRecipeType getType() { + return AllRecipes.Types.BLOCKZAPPER_UPGRADE; + } + @Override public IRecipeSerializer getSerializer() { return AllRecipes.PLACEMENT_HANDGUN_UPGRADE.serializer; @@ -90,10 +96,10 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { @Override public void write(PacketBuffer buffer, BuilderGunUpgradeRecipe recipe) { - IRecipeSerializer.CRAFTING_SHAPED.write(buffer, recipe.recipe); + IRecipeSerializer.CRAFTING_SHAPED.write(buffer, recipe.getRecipe()); - String name = recipe.component.name(); - String name2 = recipe.tier.name(); + String name = recipe.getUpgradedComponent().name(); + String name2 = recipe.getTier().name(); buffer.writeInt(name.length()); buffer.writeString(name); buffer.writeInt(name2.length()); @@ -104,7 +110,19 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe { @Override public boolean canFit(int width, int height) { - return recipe.canFit(width, height); + return getRecipe().canFit(width, height); + } + + public ShapedRecipe getRecipe() { + return recipe; + } + + public Components getUpgradedComponent() { + return component; + } + + public ComponentTier getTier() { + return tier; } } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java index 0fffb637a..639bb7ed3 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/placementHandgun/PlacementPatterns.java @@ -1,6 +1,6 @@ package com.simibubi.create.modules.curiosities.placementHandgun; -import com.simibubi.create.foundation.gui.ScreenResources; +import com.simibubi.create.ScreenResources; public enum PlacementPatterns { diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java index 459a730b0..674fb3cea 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java @@ -4,8 +4,8 @@ import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllPackets; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java index 5aad21ed4..c10fde58c 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/EntityDetectorBlock.java @@ -97,8 +97,27 @@ public class EntityDetectorBlock extends HorizontalBlock public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState state = getDefaultState(); - if (context.getFace().getAxis().isHorizontal()) { - state = state.with(HORIZONTAL_FACING, context.getFace().getOpposite()); + Direction preferredFacing = null; + for (Direction face : Direction.values()) { + if (face.getAxis().isVertical()) + continue; + + BlockState blockState = context.getWorld().getBlockState(context.getPos().offset(face)); + if (AllBlocks.BELT.typeOf(blockState) + && blockState.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() != face.getAxis() + && blockState.get(BeltBlock.SLOPE) == Slope.HORIZONTAL) + if (preferredFacing == null) + preferredFacing = face; + else { + preferredFacing = null; + break; + } + } + + if (preferredFacing != null) { + state = state.with(HORIZONTAL_FACING, preferredFacing); + } else if (context.getFace().getAxis().isHorizontal()) { + state = state.with(HORIZONTAL_FACING, context.getFace()); } else { state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing()); } @@ -221,7 +240,7 @@ public class EntityDetectorBlock extends HorizontalBlock itemPositions.add(position); } } - + @Override public float getItemHitboxScale() { return 1.76f / 16f; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/FlexcrateScreen.java b/src/main/java/com/simibubi/create/modules/logistics/block/FlexcrateScreen.java index b573915f8..d148a057b 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/FlexcrateScreen.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/FlexcrateScreen.java @@ -1,14 +1,14 @@ package com.simibubi.create.modules.logistics.block; -import static com.simibubi.create.foundation.gui.ScreenResources.FLEXCRATE; -import static com.simibubi.create.foundation.gui.ScreenResources.PLAYER_INVENTORY; +import static com.simibubi.create.ScreenResources.FLEXCRATE; +import static com.simibubi.create.ScreenResources.PLAYER_INVENTORY; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; import com.simibubi.create.foundation.gui.ScreenElementRenderer; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchBlock.java index 765dc0ad3..23fa288d8 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchBlock.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchBlock.java @@ -21,6 +21,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.items.CapabilityItemHandler; public class StockswitchBlock extends HorizontalBlock { @@ -34,12 +35,12 @@ public class StockswitchBlock extends HorizontalBlock { public boolean isSolid(BlockState state) { return false; } - + @Override public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { updateObservedInventory(state, worldIn, pos); } - + @Override public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { if (world.isRemote()) @@ -48,32 +49,32 @@ public class StockswitchBlock extends HorizontalBlock { return; updateObservedInventory(state, world, pos); } - + private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) { StockswitchTileEntity te = (StockswitchTileEntity) world.getTileEntity(pos); if (te == null) return; te.updateCurrentLevel(); } - + private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) { return observing.equals(pos.offset(state.get(HORIZONTAL_FACING))); } - + @Override public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { return side != null && side.getOpposite() != state.get(HORIZONTAL_FACING); } - + @Override public boolean canProvidePower(BlockState state) { return true; } - + @Override public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { StockswitchTileEntity te = (StockswitchTileEntity) blockAccess.getTileEntity(pos); - return te == null || !te.powered ? 0 : 15 ; + return te == null || !te.powered ? 0 : 15; } @Override @@ -100,10 +101,27 @@ public class StockswitchBlock extends HorizontalBlock { public BlockState getStateForPlacement(BlockItemUseContext context) { BlockState state = getDefaultState(); - if (context.getFace().getAxis().isHorizontal()) { - state = state.with(HORIZONTAL_FACING, context.getFace().getOpposite()); + Direction preferredFacing = null; + for (Direction face : Direction.values()) { + if (face.getAxis().isVertical()) + continue; + + TileEntity te = context.getWorld().getTileEntity(context.getPos().offset(face)); + if (te != null && te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent()) + if (preferredFacing == null) + preferredFacing = face; + else { + preferredFacing = null; + break; + } + } + + if (preferredFacing != null) { + state = state.with(HORIZONTAL_FACING, preferredFacing); + } else if (context.getFace().getAxis().isHorizontal()) { + state = state.with(HORIZONTAL_FACING, context.getFace()); } else { - state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing()); + state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); } return state; diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java index 3dcb21ba4..801e19772 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java @@ -1,15 +1,15 @@ package com.simibubi.create.modules.logistics.block; -import static com.simibubi.create.foundation.gui.ScreenResources.STOCKSWITCH; +import static com.simibubi.create.ScreenResources.STOCKSWITCH; import java.util.Arrays; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.ScreenElementRenderer; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java index 3a0b44198..86accd556 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicTableScreen.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.schematics.block; -import static com.simibubi.create.foundation.gui.ScreenResources.SCHEMATIC_TABLE; -import static com.simibubi.create.foundation.gui.ScreenResources.SCHEMATIC_TABLE_PROGRESS; +import static com.simibubi.create.ScreenResources.SCHEMATIC_TABLE; +import static com.simibubi.create.ScreenResources.SCHEMATIC_TABLE_PROGRESS; import java.nio.file.Paths; import java.util.List; @@ -9,8 +9,8 @@ import java.util.List; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java index ffb726b90..dea178076 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java @@ -10,8 +10,8 @@ import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.Indicator; import com.simibubi.create.foundation.gui.widgets.Indicator.State; diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/BlueprintHotbarOverlay.java b/src/main/java/com/simibubi/create/modules/schematics/client/BlueprintHotbarOverlay.java index bba678a52..125d09bd1 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/BlueprintHotbarOverlay.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/BlueprintHotbarOverlay.java @@ -1,7 +1,7 @@ package com.simibubi.create.modules.schematics.client; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.foundation.gui.ScreenResources; +import com.simibubi.create.ScreenResources; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicEditScreen.java b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicEditScreen.java index f4aae8c14..eb99c1fd4 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/SchematicEditScreen.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/SchematicEditScreen.java @@ -6,8 +6,8 @@ import java.util.List; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.AllItems; import com.simibubi.create.CreateClient; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; -import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; diff --git a/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java b/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java index 60a090217..2b6965d2b 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java +++ b/src/main/java/com/simibubi/create/modules/schematics/client/tools/Tools.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.simibubi.create.foundation.gui.ScreenResources; +import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.utility.Lang; public enum Tools { diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index b57e5e916..4ec27263b 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -19,6 +19,7 @@ "item.create.refined_rose_quartz": "Refined Rose Quartz", "item.create.refined_radiance_cube": "Refined Radiance", "item.create.iron_sheet": "Iron Sheets", + "item.create.gold_sheet": "Gold Sheets", "item.create.propeller": "Propeller", "item.create.flour": "Wheat Flour", "item.create.dough": "Dough", @@ -144,6 +145,17 @@ "death.attack.create.fan_lava": "%1$s was burned to death by lava fan", "death.attack.create.drill": "%1$s was impaled by Mechanical Drill", + "create.recipe.crushing": "Crushing", + "create.recipe.splashing": "Bulk Washing", + "create.recipe.splashing.fan": "Fan behind §9Flowing Water", + "create.recipe.smokingViaFan": "Bulk Smoking", + "create.recipe.smokingViaFan.fan": "Fan behind §6Fire", + "create.recipe.blastingViaFan": "Bulk Smelting", + "create.recipe.blastingViaFan.fan": "Fan behind §6Lava", + "create.recipe.pressing": "Mechanical Press", + "create.recipe.blockzapperUpgrade": "Handheld Blockzapper", + "create.recipe.processing.chance": "%1$s%% Chance", + "create.generic.range": "Range", "create.generic.radius": "Radius", "create.generic.speed": "Speed", @@ -363,6 +375,29 @@ "item.create.tree_fertilizer.tooltip.condition1": "When used on Sapling", "item.create.tree_fertilizer.tooltip.behaviour1": "Grows Trees regardless of their spacing Conditions", + "item.create.empty_blueprint.tooltip": "EMPTY SCHEMATIC", + "item.create.empty_blueprint.tooltip.summary": "Used as a recipe ingredient and for writing at the _Schematic_ _Table._", + + "item.create.blueprint.tooltip": "SCHEMATIC", + "item.create.blueprint.tooltip.summary": "Holds a structure to be positioned and placed into the world. Position the Hologram as desired and use a _Schematicannon_ to build it.", + "item.create.blueprint.tooltip.condition1": "When Held", + "item.create.blueprint.tooltip.behaviour1": "Can be positioned using the Tools on Screen", + "item.create.blueprint.tooltip.control1": "R-Click while Sneaking", + "item.create.blueprint.tooltip.action1": "Opens an _Interface_ for entering exact _Coordinates._", + + "item.create.blueprint_and_quill.tooltip": "SCHEMATIC AND QUILL", + "item.create.blueprint_and_quill.tooltip.summary": "Used for saving a Structure in your world to a .nbt file.", + "item.create.blueprint_and_quill.tooltip.condition1": "Step 1", + "item.create.blueprint_and_quill.tooltip.behaviour1": "Select two corner points using R-Click", + "item.create.blueprint_and_quill.tooltip.condition2": "Step 2", + "item.create.blueprint_and_quill.tooltip.behaviour2": "_Ctrl-Scroll_ on the faces to adjust the size. R-Click again to Save.", + "item.create.blueprint_and_quill.tooltip.control1": "R-Click", + "item.create.blueprint_and_quill.tooltip.action1": "Select a corner point / confirm save", + "item.create.blueprint_and_quill.tooltip.control2": "Ctrl Held", + "item.create.blueprint_and_quill.tooltip.action2": "Select points in _mid-air_. _Scroll_ to adjust the distance.", + "item.create.blueprint_and_quill.tooltip.control3": "R-Click while Sneaking", + "item.create.blueprint_and_quill.tooltip.action3": "_Resets_ and removes the selection.", + "block.create.creative_crate.tooltip": "CREATIVE CRATE", "block.create.creative_crate.tooltip.summary": "tis a crate", diff --git a/src/main/resources/assets/create/models/item/gold_sheet.json b/src/main/resources/assets/create/models/item/gold_sheet.json new file mode 100644 index 000000000..84fabd09e --- /dev/null +++ b/src/main/resources/assets/create/models/item/gold_sheet.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "create:item/gold_sheet" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/gui/recipes1.png b/src/main/resources/assets/create/textures/gui/recipes1.png new file mode 100644 index 000000000..49228f8aa Binary files /dev/null and b/src/main/resources/assets/create/textures/gui/recipes1.png differ diff --git a/src/main/resources/assets/create/textures/gui/recipes2.png b/src/main/resources/assets/create/textures/gui/recipes2.png new file mode 100644 index 000000000..a6eddc19f Binary files /dev/null and b/src/main/resources/assets/create/textures/gui/recipes2.png differ diff --git a/src/main/resources/assets/create/textures/item/gold_sheet.png b/src/main/resources/assets/create/textures/item/gold_sheet.png new file mode 100644 index 000000000..5464e5813 Binary files /dev/null and b/src/main/resources/assets/create/textures/item/gold_sheet.png differ diff --git a/src/main/resources/data/create/recipes/crafting/belt_funnel.json b/src/main/resources/data/create/recipes/crafting/belt_funnel.json index 830b3da8b..ef3356b01 100644 --- a/src/main/resources/data/create/recipes/crafting/belt_funnel.json +++ b/src/main/resources/data/create/recipes/crafting/belt_funnel.json @@ -1,16 +1,16 @@ { "type": "crafting_shaped", "pattern": [ - "N ", - "P ", - "ND" + "NN", + "PD", + "PD" ], "key": { "D": { "item": "minecraft:dried_kelp" }, "N": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" }, "P": { "tag": "minecraft:planks" @@ -18,7 +18,7 @@ }, "result": { "item": "create:belt_funnel", - "count": 1 + "count": 4 }, "conditions": [ { diff --git a/src/main/resources/data/create/recipes/crafting/belt_support.json b/src/main/resources/data/create/recipes/crafting/belt_support.json new file mode 100644 index 000000000..b1b9518c2 --- /dev/null +++ b/src/main/resources/data/create/recipes/crafting/belt_support.json @@ -0,0 +1,26 @@ +{ + "type": "crafting_shaped", + "pattern": [ + "N", + "P", + "P" + ], + "key": { + "N": { + "item": "create:gold_sheet" + }, + "P": { + "tag": "minecraft:planks" + } + }, + "result": { + "item": "create:belt_support", + "count": 4 + }, + "conditions": [ + { + "type": "create:module", + "module": "logistics" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crafting/clutch.json b/src/main/resources/data/create/recipes/crafting/clutch.json index fe2b2e4a9..b0db25466 100644 --- a/src/main/resources/data/create/recipes/crafting/clutch.json +++ b/src/main/resources/data/create/recipes/crafting/clutch.json @@ -10,7 +10,7 @@ "tag": "minecraft:planks" }, "A": { - "item": "create:andesite_alloy_cube" + "item": "create:iron_sheet" }, "S": { "item": "create:shaft" diff --git a/src/main/resources/data/create/recipes/crafting/contact.json b/src/main/resources/data/create/recipes/crafting/contact.json index 0b40c1e29..72c1b68a7 100644 --- a/src/main/resources/data/create/recipes/crafting/contact.json +++ b/src/main/resources/data/create/recipes/crafting/contact.json @@ -16,7 +16,7 @@ "item": "minecraft:redstone" }, "G": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" } }, "result": { diff --git a/src/main/resources/data/create/recipes/crafting/encased_fan.json b/src/main/resources/data/create/recipes/crafting/encased_fan.json index ae505f03e..5c57844f9 100644 --- a/src/main/resources/data/create/recipes/crafting/encased_fan.json +++ b/src/main/resources/data/create/recipes/crafting/encased_fan.json @@ -10,7 +10,7 @@ "item": "minecraft:iron_bars" }, "A": { - "item": "create:andesite_alloy_cube" + "item": "create:iron_sheet" }, "S": { "item": "create:propeller" diff --git a/src/main/resources/data/create/recipes/crafting/entity_detector.json b/src/main/resources/data/create/recipes/crafting/entity_detector.json index 5c5184a6d..786d32a08 100644 --- a/src/main/resources/data/create/recipes/crafting/entity_detector.json +++ b/src/main/resources/data/create/recipes/crafting/entity_detector.json @@ -10,7 +10,7 @@ "tag": "minecraft:planks" }, "A": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" }, "S": { "item": "minecraft:observer" diff --git a/src/main/resources/data/create/recipes/crafting/extractor.json b/src/main/resources/data/create/recipes/crafting/extractor.json index 50766a887..69ef667fc 100644 --- a/src/main/resources/data/create/recipes/crafting/extractor.json +++ b/src/main/resources/data/create/recipes/crafting/extractor.json @@ -16,7 +16,7 @@ "item": "minecraft:dried_kelp" }, "N": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" }, "P": { "tag": "minecraft:planks" @@ -24,7 +24,7 @@ }, "result": { "item": "create:extractor", - "count": 1 + "count": 4 }, "conditions": [ { diff --git a/src/main/resources/data/create/recipes/crafting/flexcrate.json b/src/main/resources/data/create/recipes/crafting/flexcrate.json index a88bb7faf..9cbd917be 100644 --- a/src/main/resources/data/create/recipes/crafting/flexcrate.json +++ b/src/main/resources/data/create/recipes/crafting/flexcrate.json @@ -10,7 +10,7 @@ "tag": "minecraft:planks" }, "A": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" }, "S": { "item": "minecraft:chest" @@ -18,7 +18,7 @@ }, "result": { "item": "create:flexcrate", - "count": 1 + "count": 2 }, "conditions": [ { diff --git a/src/main/resources/data/create/recipes/crafting/gearshift.json b/src/main/resources/data/create/recipes/crafting/gearshift.json index 16e6c600a..7ce1869f4 100644 --- a/src/main/resources/data/create/recipes/crafting/gearshift.json +++ b/src/main/resources/data/create/recipes/crafting/gearshift.json @@ -10,7 +10,7 @@ "tag": "minecraft:planks" }, "A": { - "item": "create:andesite_alloy_cube" + "item": "create:iron_sheet" }, "S": { "item": "create:cogwheel" diff --git a/src/main/resources/data/create/recipes/crafting/harvester.json b/src/main/resources/data/create/recipes/crafting/harvester.json index 223866399..deb1bef86 100644 --- a/src/main/resources/data/create/recipes/crafting/harvester.json +++ b/src/main/resources/data/create/recipes/crafting/harvester.json @@ -7,7 +7,7 @@ ], "key": { "A": { - "item": "create:andesite_alloy_cube" + "item": "create:iron_sheet" }, "I": { "item": "minecraft:iron_nugget" diff --git a/src/main/resources/data/create/recipes/crafting/motor.json b/src/main/resources/data/create/recipes/crafting/motor.json index 60dd5b2d8..5bc80460f 100644 --- a/src/main/resources/data/create/recipes/crafting/motor.json +++ b/src/main/resources/data/create/recipes/crafting/motor.json @@ -10,7 +10,7 @@ "item": "create:blaze_brass_cube" }, "A": { - "item": "create:andesite_alloy_cube" + "item": "create:iron_sheet" }, "I": { "item": "minecraft:iron_block" diff --git a/src/main/resources/data/create/recipes/crafting/redstone_bridge.json b/src/main/resources/data/create/recipes/crafting/redstone_bridge.json index 351155d30..a5c46d639 100644 --- a/src/main/resources/data/create/recipes/crafting/redstone_bridge.json +++ b/src/main/resources/data/create/recipes/crafting/redstone_bridge.json @@ -9,7 +9,7 @@ "tag": "minecraft:planks" }, "G": { - "item": "minecraft:gold_ingot" + "item": "create:gold_sheet" }, "T": { "item": "minecraft:redstone_torch" diff --git a/src/main/resources/data/create/recipes/crafting/stockswitch.json b/src/main/resources/data/create/recipes/crafting/stockswitch.json index d336248d0..e2fe37d6e 100644 --- a/src/main/resources/data/create/recipes/crafting/stockswitch.json +++ b/src/main/resources/data/create/recipes/crafting/stockswitch.json @@ -16,7 +16,7 @@ "item": "minecraft:comparator" }, "G": { - "item": "minecraft:gold_nugget" + "item": "create:gold_sheet" } }, "result": { diff --git a/src/main/resources/data/create/recipes/pressing/gold_ingot.json b/src/main/resources/data/create/recipes/pressing/gold_ingot.json new file mode 100644 index 000000000..76b05f691 --- /dev/null +++ b/src/main/resources/data/create/recipes/pressing/gold_ingot.json @@ -0,0 +1,16 @@ +{ + "type": "create:pressing", + "group": "minecraft:misc", + "ingredients": [ + { + "item": "minecraft:gold_ingot" + } + ], + "results": [ + { + "item": "create:gold_sheet", + "count": 1 + } + ], + "processingTime": 100 +} \ No newline at end of file