JEI integration & Placement QOL

- Added JEI support for all added recipe types
- Changed a few recipes
- Kinetic blocks with shafts now try to connect to other shafts when placed
This commit is contained in:
simibubi 2019-09-16 12:27:28 +02:00
parent 0d924bc1f7
commit e95060f997
64 changed files with 1381 additions and 97 deletions

View file

@ -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 { dependencies {
minecraft 'net.minecraftforge:forge:1.14.4-28.0.102' 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 { jar {

View file

@ -42,6 +42,7 @@ public enum AllItems {
__MATERIALS__(), __MATERIALS__(),
IRON_SHEET(ingredient()), IRON_SHEET(ingredient()),
GOLD_SHEET(ingredient()),
ANDESITE_ALLOY_CUBE(ingredient()), ANDESITE_ALLOY_CUBE(ingredient()),
BLAZE_BRASS_CUBE(ingredient()), BLAZE_BRASS_CUBE(ingredient()),
CHORUS_CHROME_CUBE(ingredient(Rarity.UNCOMMON)), CHORUS_CHROME_CUBE(ingredient(Rarity.UNCOMMON)),

View file

@ -18,19 +18,10 @@ import net.minecraftforge.event.RegistryEvent;
public enum AllRecipes { public enum AllRecipes {
PLACEMENT_HANDGUN_UPGRADE(BuilderGunUpgradeRecipe.Serializer::new, IRecipeType.CRAFTING), PLACEMENT_HANDGUN_UPGRADE(BuilderGunUpgradeRecipe.Serializer::new, Types.BLOCKZAPPER_UPGRADE),
CRUSHING(() -> new ProcessingRecipeSerializer<>(CrushingRecipe::new), Types.CRUSHING),
CRUSHING(() -> { SPLASHING(() -> new ProcessingRecipeSerializer<>(SplashingRecipe::new), Types.SPLASHING),
return new ProcessingRecipeSerializer<>(CrushingRecipe::new); PRESSING(() -> new ProcessingRecipeSerializer<>(PressingRecipe::new), Types.PRESSING),
}, Types.CRUSHING),
SPLASHING(() -> {
return new ProcessingRecipeSerializer<>(SplashingRecipe::new);
}, Types.SPLASHING),
PRESSING(() -> {
return new ProcessingRecipeSerializer<>(PressingRecipe::new);
}, Types.PRESSING),
; ;
@ -38,6 +29,7 @@ public enum AllRecipes {
public static IRecipeType<CrushingRecipe> CRUSHING = register("crushing"); public static IRecipeType<CrushingRecipe> CRUSHING = register("crushing");
public static IRecipeType<SplashingRecipe> SPLASHING = register("splashing"); public static IRecipeType<SplashingRecipe> SPLASHING = register("splashing");
public static IRecipeType<PressingRecipe> PRESSING = register("pressing"); public static IRecipeType<PressingRecipe> PRESSING = register("pressing");
public static IRecipeType<BuilderGunUpgradeRecipe> BLOCKZAPPER_UPGRADE = register("blockzapper_upgrade");
static <T extends IRecipe<?>> IRecipeType<T> register(final String key) { static <T extends IRecipe<?>> IRecipeType<T> register(final String key) {
return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IRecipeType<T>() { return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IRecipeType<T>() {

View file

@ -3,6 +3,7 @@ package com.simibubi.create;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.compat.jei.AnimatedKinetics;
import com.simibubi.create.foundation.block.IBlockWithScrollableValue; import com.simibubi.create.foundation.block.IBlockWithScrollableValue;
import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.utility.TooltipHelper; import com.simibubi.create.foundation.utility.TooltipHelper;
@ -36,6 +37,9 @@ public class ClientEvents {
public static void onTick(ClientTickEvent event) { public static void onTick(ClientTickEvent event) {
if (event.phase == Phase.START) if (event.phase == Phase.START)
return; return;
AnimatedKinetics.tick();
if (!isGameActive()) if (!isGameActive())
return; return;

View file

@ -1,6 +1,4 @@
package com.simibubi.create.foundation.gui; package com.simibubi.create;
import com.simibubi.create.Create;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui; 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_LEFT("flex_crate_and_stockpile_switch.png", 234, 129, 7, 21),
STOCKSWITCH_BOUND_RIGHT("flex_crate_and_stockpile_switch.png", 241, 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 // Widgets
PALETTE_BUTTON("palette_picker.png", 0, 236, 20, 20), PALETTE_BUTTON("palette_picker.png", 0, 236, 20, 20),
TEXT_INPUT("widgets.png", 0, 28, 194, 47), TEXT_INPUT("widgets.png", 0, 28, 194, 47),

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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<AbstractCookingRecipe> {
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<? extends AbstractCookingRecipe> 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();
}
}

View file

@ -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<BuilderGunUpgradeRecipe> {
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<? extends BuilderGunUpgradeRecipe> 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<Ingredient> 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<String> getTooltipStrings(BuilderGunUpgradeRecipe recipe, double mouseX, double mouseY) {
List<String> 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();
}
}

View file

@ -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<IRecipe<?>> findRecipes(AllRecipes recipe) {
return findRecipesByType(recipe.type);
}
private static List<IRecipe<?>> findRecipesByType(IRecipeType<?> type) {
return Minecraft.getInstance().world.getRecipeManager().getRecipes().stream().filter(r -> r.getType() == type)
.collect(Collectors.toList());
}
private static List<IRecipe<?>> findRecipesByTypeExcluding(IRecipeType<?> type, IRecipeType<?> excludingType) {
List<IRecipe<?>> byType = findRecipesByType(type);
List<IRecipe<?>> 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;
}
}

View file

@ -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<CrushingRecipe> {
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<? extends CrushingRecipe> 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<StochasticOutput> 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);
}
}

View file

@ -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<ItemStack> primarySupplier;
private Supplier<ItemStack> secondarySupplier;
private ItemStack primaryStack;
private ItemStack secondaryStack;
public DoubleItemIcon(Supplier<ItemStack> primary, Supplier<ItemStack> 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();
}
}

View file

@ -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<PressingRecipe> {
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<? extends PressingRecipe> 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<StochasticOutput> 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);
}
}

View file

@ -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<T extends IRecipe<?>> implements IRecipeCategory<T> {
@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();
}

View file

@ -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);
}
}

View file

@ -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<SmokingRecipe> {
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<? extends SmokingRecipe> getRecipeClass() {
return SmokingRecipe.class;
}
@Override
public String getTitle() {
return Lang.translate("recipe.smokingViaFan");
}
@Override
public void renderAttachedBlock() {
ScreenElementRenderer.renderBlock(() -> Blocks.FIRE.getDefaultState());
}
}

View file

@ -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<SplashingRecipe> {
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<? extends SplashingRecipe> 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();
}
}

View file

@ -2,13 +2,19 @@ package com.simibubi.create.foundation.gui;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
public class ScreenElementRenderer { public class ScreenElementRenderer {
@ -46,6 +52,17 @@ public class ScreenElementRenderer {
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
mc.getBlockRendererDispatcher().renderBlockBrightness(toRender, 1); 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.disableAlphaTest();
GlStateManager.disableRescaleNormal(); GlStateManager.disableRescaleNormal();

View file

@ -4,6 +4,7 @@ import java.util.function.Consumer;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.widget.TextFieldWidget;

View file

@ -5,6 +5,7 @@ import java.util.function.Consumer;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllKeys; import com.simibubi.create.AllKeys;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.schematics.client.tools.Tools; import com.simibubi.create.modules.schematics.client.tools.Tools;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.foundation.gui.widgets; package com.simibubi.create.foundation.gui.widgets;
import com.mojang.blaze3d.platform.GlStateManager; 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.client.Minecraft;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.foundation.gui.widgets; package com.simibubi.create.foundation.gui.widgets;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.ScreenResources;
public class Indicator extends AbstractSimiWidget { public class Indicator extends AbstractSimiWidget {

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.base;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.simibubi.create.AllRecipes; import com.simibubi.create.AllRecipes;
@ -16,15 +17,15 @@ import net.minecraft.util.ResourceLocation;
public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<T> { public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<T> {
protected final List<Ingredient> ingredients; protected final List<Ingredient> ingredients;
protected final List<StochasticOutput> results; private final List<StochasticOutput> results;
private final IRecipeType<?> type; private final IRecipeType<?> type;
private final IRecipeSerializer<?> serializer; private final IRecipeSerializer<?> serializer;
protected final ResourceLocation id; protected final ResourceLocation id;
protected final String group; protected final String group;
protected final int processingDuration; protected final int processingDuration;
public ProcessingRecipe(AllRecipes recipeType, ResourceLocation id, String group, public ProcessingRecipe(AllRecipes recipeType, ResourceLocation id, String group, List<Ingredient> ingredients,
List<Ingredient> ingredients, List<StochasticOutput> results, int processingDuration) { List<StochasticOutput> results, int processingDuration) {
this.type = recipeType.type; this.type = recipeType.type;
this.serializer = recipeType.serializer; this.serializer = recipeType.serializer;
this.id = id; this.id = id;
@ -40,18 +41,14 @@ public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<
nonnulllist.addAll(this.ingredients); nonnulllist.addAll(this.ingredients);
return nonnulllist; return nonnulllist;
} }
public int getProcessingDuration() { public int getProcessingDuration() {
return processingDuration; return processingDuration;
} }
public List<StochasticOutput> getAllResults() {
return results;
}
public List<ItemStack> rollResults() { public List<ItemStack> rollResults() {
List<ItemStack> stacks = new ArrayList<>(); List<ItemStack> stacks = new ArrayList<>();
for (StochasticOutput output : results) { for (StochasticOutput output : getRollableResults()) {
ItemStack stack = output.rollOutput(); ItemStack stack = output.rollOutput();
if (!stack.isEmpty()) if (!stack.isEmpty())
stacks.add(stack); stacks.add(stack);
@ -71,7 +68,7 @@ public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<
@Override @Override
public ItemStack getRecipeOutput() { public ItemStack getRecipeOutput() {
return results.isEmpty() ? ItemStack.EMPTY : results.get(0).getStack(); return getRollableResults().isEmpty() ? ItemStack.EMPTY : getRollableResults().get(0).getStack();
} }
@Override @Override
@ -83,7 +80,7 @@ public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<
public IRecipeSerializer<?> getSerializer() { public IRecipeSerializer<?> getSerializer() {
return serializer; return serializer;
} }
@Override @Override
public String getGroup() { public String getGroup() {
return group; return group;
@ -93,4 +90,12 @@ public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<
public IRecipeType<?> getType() { public IRecipeType<?> getType() {
return type; return type;
} }
public List<StochasticOutput> getRollableResults() {
return results;
}
public List<ItemStack> getPossibleOutputs() {
return getRollableResults().stream().map(output -> output.getStack()).collect(Collectors.toList());
}
} }

View file

@ -70,8 +70,8 @@ public class ProcessingRecipeSerializer<T extends ProcessingRecipe<?>>
buffer.writeInt(recipe.ingredients.size()); buffer.writeInt(recipe.ingredients.size());
recipe.ingredients.forEach(i -> i.write(buffer)); recipe.ingredients.forEach(i -> i.write(buffer));
buffer.writeInt(recipe.results.size()); buffer.writeInt(recipe.getRollableResults().size());
recipe.results.forEach(i -> i.write(buffer)); recipe.getRollableResults().forEach(i -> i.write(buffer));
buffer.writeInt(recipe.processingDuration); buffer.writeInt(recipe.processingDuration);
} }

View file

@ -7,6 +7,7 @@ import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Rotation; import net.minecraft.util.Rotation;
public abstract class RotatedPillarKineticBlock extends KineticBlock { public abstract class RotatedPillarKineticBlock extends KineticBlock {
@ -35,6 +36,24 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock {
return state; 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 @Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {

View file

@ -7,6 +7,7 @@ import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
@ -40,6 +41,14 @@ public class MotorBlock extends HorizontalKineticBlock
return new MotorTileEntity(); 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: // IRotate:
@Override @Override

View file

@ -1,13 +1,16 @@
package com.simibubi.create.modules.contraptions.receivers; package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.modules.contraptions.relays.EncasedShaftBlock; import com.simibubi.create.modules.contraptions.relays.EncasedShaftBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld; 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, public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) { boolean isMoving) {
notifyFanTile(worldIn, pos); notifyFanTile(worldIn, pos);
if (worldIn.isRemote || state.get(AXIS).isHorizontal()) if (worldIn.isRemote || state.get(AXIS).isHorizontal())
return; return;
withTileEntityDo(worldIn, pos, EncasedFanTileEntity::updateGenerator); 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) { protected void notifyFanTile(IWorld world, BlockPos pos) {
withTileEntityDo(world, pos, EncasedFanTileEntity::updateFrontBlock); withTileEntityDo(world, pos, EncasedFanTileEntity::updateFrontBlock);
} }

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig; import com.simibubi.create.CreateConfig;
import com.simibubi.create.modules.contraptions.base.IRotate;
import com.simibubi.create.modules.contraptions.base.KineticBlock; import com.simibubi.create.modules.contraptions.base.KineticBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -19,7 +20,6 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos; 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.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.VoxelShapes;
@ -63,13 +63,48 @@ public class MechanicalPistonBlock extends KineticBlock {
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
Direction facing = context.getNearestLookingDirection().getOpposite(); Direction facing = context.getNearestLookingDirection().getOpposite();
BlockPos pos = context.getPos();
World world = context.getWorld();
boolean alongFirst = false;
if (context.isPlacerSneaking()) if (context.isPlacerSneaking())
facing = facing.getOpposite(); facing = facing.getOpposite();
Vec3d diff = context.getHitVec().subtract(new Vec3d(context.getPos())); if (facing.getAxis().isHorizontal()) {
double firstCoord = facing.getAxis() == Axis.X ? diff.y : diff.x; alongFirst = facing.getAxis() == Axis.Z;
double secondCoord = facing.getAxis() == Axis.Z ? diff.y : diff.z;
boolean alongFirst = firstCoord + secondCoord < 1 ^ firstCoord < secondCoord; 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) return this.getDefaultState().with(FACING, facing).with(STATE, PistonState.RETRACTED)
.with(AXIS_ALONG_FIRST_COORDINATE, alongFirst); .with(AXIS_ALONG_FIRST_COORDINATE, alongFirst);

View file

@ -38,7 +38,9 @@ public class EncasedShaftBlock extends RotatedPillarKineticBlock {
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
if (context.isPlacerSneaking()) if (context.isPlacerSneaking())
return super.getStateForPlacement(context); 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 @Override

View file

@ -1,12 +1,16 @@
package com.simibubi.create.modules.contraptions.relays; package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.modules.contraptions.base.IRotate;
import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.material.PushReaction; import net.minecraft.block.material.PushReaction;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -27,6 +31,52 @@ public class GearboxBlock extends RotatedPillarKineticBlock {
return PushReaction.PUSH_ONLY; 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: // IRotate:
@Override @Override

View file

@ -72,7 +72,7 @@ public class BuilderGunItem extends Item {
; ;
protected TextFormatting color; public TextFormatting color;
private ComponentTier(TextFormatting color) { private ComponentTier(TextFormatting color) {
this.color = color; this.color = color;

View file

@ -7,8 +7,8 @@ import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiScreen; 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.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator; import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Indicator.State; import com.simibubi.create.foundation.gui.widgets.Indicator.State;

View file

@ -10,6 +10,7 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe; import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.item.crafting.ShapedRecipe;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils; import net.minecraft.util.JSONUtils;
@ -31,7 +32,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
@Override @Override
public boolean matches(CraftingInventory inv, World worldIn) { public boolean matches(CraftingInventory inv, World worldIn) {
return recipe.matches(inv, worldIn); return getRecipe().matches(inv, worldIn);
} }
@Override @Override
@ -40,7 +41,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
ItemStack handgun = inv.getStackInSlot(slot).copy(); ItemStack handgun = inv.getStackInSlot(slot).copy();
if (!AllItems.PLACEMENT_HANDGUN.typeOf(handgun)) if (!AllItems.PLACEMENT_HANDGUN.typeOf(handgun))
continue; continue;
BuilderGunItem.setTier(component, tier, handgun); BuilderGunItem.setTier(getUpgradedComponent(), getTier(), handgun);
return handgun; return handgun;
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
@ -49,7 +50,7 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
@Override @Override
public ItemStack getRecipeOutput() { public ItemStack getRecipeOutput() {
ItemStack handgun = new ItemStack(AllItems.PLACEMENT_HANDGUN.get()); ItemStack handgun = new ItemStack(AllItems.PLACEMENT_HANDGUN.get());
BuilderGunItem.setTier(component, tier, handgun); BuilderGunItem.setTier(getUpgradedComponent(), getTier(), handgun);
return handgun; return handgun;
} }
@ -60,9 +61,14 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
@Override @Override
public ResourceLocation getId() { public ResourceLocation getId() {
return recipe.getId(); return getRecipe().getId();
} }
@Override
public IRecipeType<?> getType() {
return AllRecipes.Types.BLOCKZAPPER_UPGRADE;
}
@Override @Override
public IRecipeSerializer<?> getSerializer() { public IRecipeSerializer<?> getSerializer() {
return AllRecipes.PLACEMENT_HANDGUN_UPGRADE.serializer; return AllRecipes.PLACEMENT_HANDGUN_UPGRADE.serializer;
@ -90,10 +96,10 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
@Override @Override
public void write(PacketBuffer buffer, BuilderGunUpgradeRecipe recipe) { 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 name = recipe.getUpgradedComponent().name();
String name2 = recipe.tier.name(); String name2 = recipe.getTier().name();
buffer.writeInt(name.length()); buffer.writeInt(name.length());
buffer.writeString(name); buffer.writeString(name);
buffer.writeInt(name2.length()); buffer.writeInt(name2.length());
@ -104,7 +110,19 @@ public class BuilderGunUpgradeRecipe implements ICraftingRecipe {
@Override @Override
public boolean canFit(int width, int height) { 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;
} }
} }

View file

@ -1,6 +1,6 @@
package com.simibubi.create.modules.curiosities.placementHandgun; package com.simibubi.create.modules.curiosities.placementHandgun;
import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.ScreenResources;
public enum PlacementPatterns { public enum PlacementPatterns {

View file

@ -4,8 +4,8 @@ import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiScreen; 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.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;

View file

@ -97,8 +97,27 @@ public class EntityDetectorBlock extends HorizontalBlock
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
BlockState state = getDefaultState(); BlockState state = getDefaultState();
if (context.getFace().getAxis().isHorizontal()) { Direction preferredFacing = null;
state = state.with(HORIZONTAL_FACING, context.getFace().getOpposite()); 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 { } else {
state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing()); state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing());
} }
@ -221,7 +240,7 @@ public class EntityDetectorBlock extends HorizontalBlock
itemPositions.add(position); itemPositions.add(position);
} }
} }
@Override @Override
public float getItemHitboxScale() { public float getItemHitboxScale() {
return 1.76f / 16f; return 1.76f / 16f;

View file

@ -1,14 +1,14 @@
package com.simibubi.create.modules.logistics.block; package com.simibubi.create.modules.logistics.block;
import static com.simibubi.create.foundation.gui.ScreenResources.FLEXCRATE; import static com.simibubi.create.ScreenResources.FLEXCRATE;
import static com.simibubi.create.foundation.gui.ScreenResources.PLAYER_INVENTORY; import static com.simibubi.create.ScreenResources.PLAYER_INVENTORY;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import com.simibubi.create.foundation.gui.ScreenElementRenderer; 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.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;

View file

@ -21,6 +21,7 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.items.CapabilityItemHandler;
public class StockswitchBlock extends HorizontalBlock { public class StockswitchBlock extends HorizontalBlock {
@ -34,12 +35,12 @@ public class StockswitchBlock extends HorizontalBlock {
public boolean isSolid(BlockState state) { public boolean isSolid(BlockState state) {
return false; return false;
} }
@Override @Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
updateObservedInventory(state, worldIn, pos); updateObservedInventory(state, worldIn, pos);
} }
@Override @Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
if (world.isRemote()) if (world.isRemote())
@ -48,32 +49,32 @@ public class StockswitchBlock extends HorizontalBlock {
return; return;
updateObservedInventory(state, world, pos); updateObservedInventory(state, world, pos);
} }
private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) { private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) {
StockswitchTileEntity te = (StockswitchTileEntity) world.getTileEntity(pos); StockswitchTileEntity te = (StockswitchTileEntity) world.getTileEntity(pos);
if (te == null) if (te == null)
return; return;
te.updateCurrentLevel(); te.updateCurrentLevel();
} }
private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) { private boolean isObserving(BlockState state, BlockPos pos, BlockPos observing) {
return observing.equals(pos.offset(state.get(HORIZONTAL_FACING))); return observing.equals(pos.offset(state.get(HORIZONTAL_FACING)));
} }
@Override @Override
public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) { public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
return side != null && side.getOpposite() != state.get(HORIZONTAL_FACING); return side != null && side.getOpposite() != state.get(HORIZONTAL_FACING);
} }
@Override @Override
public boolean canProvidePower(BlockState state) { public boolean canProvidePower(BlockState state) {
return true; return true;
} }
@Override @Override
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
StockswitchTileEntity te = (StockswitchTileEntity) blockAccess.getTileEntity(pos); StockswitchTileEntity te = (StockswitchTileEntity) blockAccess.getTileEntity(pos);
return te == null || !te.powered ? 0 : 15 ; return te == null || !te.powered ? 0 : 15;
} }
@Override @Override
@ -100,10 +101,27 @@ public class StockswitchBlock extends HorizontalBlock {
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
BlockState state = getDefaultState(); BlockState state = getDefaultState();
if (context.getFace().getAxis().isHorizontal()) { Direction preferredFacing = null;
state = state.with(HORIZONTAL_FACING, context.getFace().getOpposite()); 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 { } else {
state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing()); state = state.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
} }
return state; return state;

View file

@ -1,15 +1,15 @@
package com.simibubi.create.modules.logistics.block; 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 java.util.Arrays;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.ScreenElementRenderer; 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.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.schematics.block; package com.simibubi.create.modules.schematics.block;
import static com.simibubi.create.foundation.gui.ScreenResources.SCHEMATIC_TABLE; import static com.simibubi.create.ScreenResources.SCHEMATIC_TABLE;
import static com.simibubi.create.foundation.gui.ScreenResources.SCHEMATIC_TABLE_PROGRESS; import static com.simibubi.create.ScreenResources.SCHEMATIC_TABLE_PROGRESS;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
@ -9,8 +9,8 @@ import java.util.List;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; 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.IconButton;
import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;

View file

@ -10,8 +10,8 @@ import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets; import com.simibubi.create.AllPackets;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; 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.IconButton;
import com.simibubi.create.foundation.gui.widgets.Indicator; import com.simibubi.create.foundation.gui.widgets.Indicator;
import com.simibubi.create.foundation.gui.widgets.Indicator.State; import com.simibubi.create.foundation.gui.widgets.Indicator.State;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.schematics.client; package com.simibubi.create.modules.schematics.client;
import com.mojang.blaze3d.platform.GlStateManager; 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.MainWindow;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;

View file

@ -6,8 +6,8 @@ import java.util.List;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.AbstractSimiScreen; 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.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;

View file

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.gui.ScreenResources; import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
public enum Tools { public enum Tools {

View file

@ -19,6 +19,7 @@
"item.create.refined_rose_quartz": "Refined Rose Quartz", "item.create.refined_rose_quartz": "Refined Rose Quartz",
"item.create.refined_radiance_cube": "Refined Radiance", "item.create.refined_radiance_cube": "Refined Radiance",
"item.create.iron_sheet": "Iron Sheets", "item.create.iron_sheet": "Iron Sheets",
"item.create.gold_sheet": "Gold Sheets",
"item.create.propeller": "Propeller", "item.create.propeller": "Propeller",
"item.create.flour": "Wheat Flour", "item.create.flour": "Wheat Flour",
"item.create.dough": "Dough", "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.fan_lava": "%1$s was burned to death by lava fan",
"death.attack.create.drill": "%1$s was impaled by Mechanical Drill", "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.range": "Range",
"create.generic.radius": "Radius", "create.generic.radius": "Radius",
"create.generic.speed": "Speed", "create.generic.speed": "Speed",
@ -363,6 +375,29 @@
"item.create.tree_fertilizer.tooltip.condition1": "When used on Sapling", "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.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": "CREATIVE CRATE",
"block.create.creative_crate.tooltip.summary": "tis a crate", "block.create.creative_crate.tooltip.summary": "tis a crate",

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "create:item/gold_sheet"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

View file

@ -1,16 +1,16 @@
{ {
"type": "crafting_shaped", "type": "crafting_shaped",
"pattern": [ "pattern": [
"N ", "NN",
"P ", "PD",
"ND" "PD"
], ],
"key": { "key": {
"D": { "D": {
"item": "minecraft:dried_kelp" "item": "minecraft:dried_kelp"
}, },
"N": { "N": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
}, },
"P": { "P": {
"tag": "minecraft:planks" "tag": "minecraft:planks"
@ -18,7 +18,7 @@
}, },
"result": { "result": {
"item": "create:belt_funnel", "item": "create:belt_funnel",
"count": 1 "count": 4
}, },
"conditions": [ "conditions": [
{ {

View file

@ -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"
}
]
}

View file

@ -10,7 +10,7 @@
"tag": "minecraft:planks" "tag": "minecraft:planks"
}, },
"A": { "A": {
"item": "create:andesite_alloy_cube" "item": "create:iron_sheet"
}, },
"S": { "S": {
"item": "create:shaft" "item": "create:shaft"

View file

@ -16,7 +16,7 @@
"item": "minecraft:redstone" "item": "minecraft:redstone"
}, },
"G": { "G": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
} }
}, },
"result": { "result": {

View file

@ -10,7 +10,7 @@
"item": "minecraft:iron_bars" "item": "minecraft:iron_bars"
}, },
"A": { "A": {
"item": "create:andesite_alloy_cube" "item": "create:iron_sheet"
}, },
"S": { "S": {
"item": "create:propeller" "item": "create:propeller"

View file

@ -10,7 +10,7 @@
"tag": "minecraft:planks" "tag": "minecraft:planks"
}, },
"A": { "A": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
}, },
"S": { "S": {
"item": "minecraft:observer" "item": "minecraft:observer"

View file

@ -16,7 +16,7 @@
"item": "minecraft:dried_kelp" "item": "minecraft:dried_kelp"
}, },
"N": { "N": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
}, },
"P": { "P": {
"tag": "minecraft:planks" "tag": "minecraft:planks"
@ -24,7 +24,7 @@
}, },
"result": { "result": {
"item": "create:extractor", "item": "create:extractor",
"count": 1 "count": 4
}, },
"conditions": [ "conditions": [
{ {

View file

@ -10,7 +10,7 @@
"tag": "minecraft:planks" "tag": "minecraft:planks"
}, },
"A": { "A": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
}, },
"S": { "S": {
"item": "minecraft:chest" "item": "minecraft:chest"
@ -18,7 +18,7 @@
}, },
"result": { "result": {
"item": "create:flexcrate", "item": "create:flexcrate",
"count": 1 "count": 2
}, },
"conditions": [ "conditions": [
{ {

View file

@ -10,7 +10,7 @@
"tag": "minecraft:planks" "tag": "minecraft:planks"
}, },
"A": { "A": {
"item": "create:andesite_alloy_cube" "item": "create:iron_sheet"
}, },
"S": { "S": {
"item": "create:cogwheel" "item": "create:cogwheel"

View file

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"A": { "A": {
"item": "create:andesite_alloy_cube" "item": "create:iron_sheet"
}, },
"I": { "I": {
"item": "minecraft:iron_nugget" "item": "minecraft:iron_nugget"

View file

@ -10,7 +10,7 @@
"item": "create:blaze_brass_cube" "item": "create:blaze_brass_cube"
}, },
"A": { "A": {
"item": "create:andesite_alloy_cube" "item": "create:iron_sheet"
}, },
"I": { "I": {
"item": "minecraft:iron_block" "item": "minecraft:iron_block"

View file

@ -9,7 +9,7 @@
"tag": "minecraft:planks" "tag": "minecraft:planks"
}, },
"G": { "G": {
"item": "minecraft:gold_ingot" "item": "create:gold_sheet"
}, },
"T": { "T": {
"item": "minecraft:redstone_torch" "item": "minecraft:redstone_torch"

View file

@ -16,7 +16,7 @@
"item": "minecraft:comparator" "item": "minecraft:comparator"
}, },
"G": { "G": {
"item": "minecraft:gold_nugget" "item": "create:gold_sheet"
} }
}, },
"result": { "result": {

View file

@ -0,0 +1,16 @@
{
"type": "create:pressing",
"group": "minecraft:misc",
"ingredients": [
{
"item": "minecraft:gold_ingot"
}
],
"results": [
{
"item": "create:gold_sheet",
"count": 1
}
],
"processingTime": 100
}