diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index 667f577ca..e5e95a7ed 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -67,7 +67,7 @@ public enum AllBlockPartials { ROPE_COIL("pulley/rope_coil"), ROPE_HALF("pulley/rope_half"), ROPE_HALF_MAGNET("pulley/rope_half_magnet"), - MILL_STONE_COG("millstone/inner"), + MILLSTONE_COG("millstone/inner"), ; diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index 61a021107..4bbf9f277 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -15,6 +15,7 @@ import com.simibubi.create.compat.jei.category.BlockCuttingCategory.CondensedBlo import com.simibubi.create.compat.jei.category.BlockzapperUpgradeCategory; import com.simibubi.create.compat.jei.category.CrushingCategory; import com.simibubi.create.compat.jei.category.MechanicalCraftingCategory; +import com.simibubi.create.compat.jei.category.MillingCategory; import com.simibubi.create.compat.jei.category.MixingCategory; import com.simibubi.create.compat.jei.category.MysteriousItemConversionCategory; import com.simibubi.create.compat.jei.category.PackingCategory; @@ -55,6 +56,7 @@ import net.minecraft.util.text.TextFormatting; public class CreateJEI implements IModPlugin { private static ResourceLocation ID = new ResourceLocation(Create.ID, "jei_plugin"); + private MillingCategory millingCategory; private CrushingCategory crushingCategory; private SplashingCategory splashingCategory; private SmokingViaFanCategory smokingCategory; @@ -76,6 +78,7 @@ public class CreateJEI implements IModPlugin { } public CreateJEI() { + millingCategory = new MillingCategory(); crushingCategory = new CrushingCategory(); splashingCategory = new SplashingCategory(); pressingCategory = new PressingCategory(); @@ -99,14 +102,15 @@ public class CreateJEI implements IModPlugin { @Override public void registerCategories(IRecipeCategoryRegistration registration) { - registration.addRecipeCategories(crushingCategory, splashingCategory, pressingCategory, smokingCategory, - blastingCategory, blockzapperCategory, mixingCategory, sawingCategory, blockCuttingCategory, - packingCategory, polishingCategory, mysteryConversionCategory, smallMechanicalCraftingCategory, - largeMechanicalCraftingCategory); + registration.addRecipeCategories(millingCategory, crushingCategory, splashingCategory, pressingCategory, + smokingCategory, blastingCategory, blockzapperCategory, mixingCategory, sawingCategory, + blockCuttingCategory, packingCategory, polishingCategory, mysteryConversionCategory, + smallMechanicalCraftingCategory, largeMechanicalCraftingCategory); } @Override public void registerRecipes(IRecipeRegistration registration) { + registration.addRecipes(findRecipes(AllRecipes.MILLING), millingCategory.getUid()); registration.addRecipes(findRecipes(AllRecipes.CRUSHING), crushingCategory.getUid()); registration.addRecipes(findRecipesByTypeExcluding(AllRecipes.MILLING.getType(), AllRecipes.CRUSHING.getType()), crushingCategory.getUid()); @@ -135,12 +139,15 @@ public class CreateJEI implements IModPlugin { registration.addRecipes(findRecipes( r -> (r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), smallMechanicalCraftingCategory.getUid()); - registration.addRecipes(findRecipes(r -> r.getType() == IRecipeType.CRAFTING && (r instanceof ShapedRecipe) - && !(r instanceof MechanicalCraftingRecipe) && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), - smallMechanicalCraftingCategory.getUid()); registration.addRecipes( - findRecipes(r -> r.getType() == IRecipeType.CRAFTING && (r instanceof ShapedRecipe) - && !MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), + findRecipes( + r -> (r.getType() == IRecipeType.CRAFTING || r.getType() == AllRecipes.MECHANICAL_CRAFTING.type) + && (r instanceof ShapedRecipe) && !(r instanceof MechanicalCraftingRecipe) + && MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), + smallMechanicalCraftingCategory.getUid()); + registration.addRecipes(findRecipes( + r -> (r.getType() == IRecipeType.CRAFTING || r.getType() == AllRecipes.MECHANICAL_CRAFTING.type) + && (r instanceof ShapedRecipe) && !MechanicalCraftingCategory.isSmall((ShapedRecipe) r)), largeMechanicalCraftingCategory.getUid()); } @@ -156,6 +163,7 @@ public class CreateJEI implements IModPlugin { ItemStack blastingFan = fan.copy().setDisplayName( new StringTextComponent(TextFormatting.RESET + Lang.translate("recipe.blastingViaFan.fan"))); + registration.addRecipeCatalyst(new ItemStack(AllBlocks.MILLSTONE.get()), millingCategory.getUid()); registration.addRecipeCatalyst(new ItemStack(AllBlocks.CRUSHING_WHEEL.get()), crushingCategory.getUid()); registration.addRecipeCatalyst(splashingFan, splashingCategory.getUid()); registration.addRecipeCatalyst(smokingFan, smokingCategory.getUid()); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java index 8a4da5a26..2b4bdc07a 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java @@ -33,7 +33,7 @@ public class CrushingCategory implements IRecipeCategory public CrushingCategory() { icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.CRUSHING_WHEEL.get()), - () -> new ItemStack(AllItems.FLOUR.get())); + () -> new ItemStack(AllItems.CRUSHED_GOLD.get())); } @Override diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java new file mode 100644 index 000000000..25a555411 --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/category/MillingCategory.java @@ -0,0 +1,111 @@ +package com.simibubi.create.compat.jei.category; + +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.compat.jei.CreateJEI; +import com.simibubi.create.compat.jei.DoubleItemIcon; +import com.simibubi.create.compat.jei.EmptyBackground; +import com.simibubi.create.compat.jei.category.animations.AnimatedMillstone; +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.modules.contraptions.components.crusher.AbstractCrushingRecipe; +import com.simibubi.create.modules.contraptions.processing.ProcessingOutput; + +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 MillingCategory implements IRecipeCategory { + + private static ResourceLocation ID = new ResourceLocation(Create.ID, "milling"); + private AnimatedMillstone millstone = new AnimatedMillstone(); + private IDrawable icon; + private IDrawable background = new EmptyBackground(177, 53); + + public MillingCategory() { + icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.MILLSTONE.get()), + () -> new ItemStack(AllItems.FLOUR.get())); + } + + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public ResourceLocation getUid() { + return ID; + } + + @Override + public Class getRecipeClass() { + return AbstractCrushingRecipe.class; + } + + @Override + public String getTitle() { + return Lang.translate("recipe.milling"); + } + + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public void setIngredients(AbstractCrushingRecipe recipe, IIngredients ingredients) { + ingredients.setInputIngredients(recipe.getIngredients()); + ingredients.setOutputs(VanillaTypes.ITEM, recipe.getPossibleOutputs()); + } + + @Override + public void setRecipe(IRecipeLayout recipeLayout, AbstractCrushingRecipe recipe, IIngredients ingredients) { + IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + itemStacks.init(0, true, 14, 8); + itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + + List results = recipe.getRollableResults(); + boolean single = results.size() == 1; + for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) { + int xOffset = outputIndex % 2 == 0 ? 0 : 19; + int yOffset = (outputIndex / 2) * -19; + + itemStacks.init(outputIndex + 1, false, single ? 139 : 133 + xOffset, 27 + yOffset); + itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack()); + } + + CreateJEI.addStochasticTooltip(itemStacks, results); + } + + @Override + public void draw(AbstractCrushingRecipe recipe, double mouseX, double mouseY) { + int size = recipe.getPossibleOutputs().size(); + + ScreenResources.JEI_SLOT.draw(14, 8); + ScreenResources.JEI_SHADOW.draw(30, 40); + ScreenResources.JEI_ARROW.draw(85, 32); + ScreenResources.JEI_DOWN_ARROW.draw(43, 4); + + if (size > 1) { + for (int i = 0; i < size; i++) { + int xOffset = i % 2 == 0 ? 0 : 19; + int yOffset = (i / 2) * -19; + ScreenResources.JEI_SLOT.draw(133 + xOffset, 27 + yOffset); + } + } else { + ScreenResources.JEI_SLOT.draw(139, 27); + } + + millstone.draw(57, 27); + } + +} diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java new file mode 100644 index 000000000..0d186c50c --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java @@ -0,0 +1,55 @@ +package com.simibubi.create.compat.jei.category.animations; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.gui.ScreenElementRenderer; + +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.model.IBakedModel; + +public class AnimatedMillstone extends AnimatedKinetics { + + @Override + public int getWidth() { + return 50; + } + + @Override + public int getHeight() { + return 50; + } + + @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.renderModel(this::cogwheel); + GlStateManager.popMatrix(); + + GlStateManager.pushMatrix(); + ScreenElementRenderer.renderBlock(this::body); + GlStateManager.popMatrix(); + + GlStateManager.popMatrix(); + } + + private IBakedModel cogwheel() { + float t = 25; + GlStateManager.translatef(t, -t, -t); + GlStateManager.rotated(getCurrentAngle() * 2, 0, 1, 0); + GlStateManager.translatef(-t, t, t); + return AllBlockPartials.MILLSTONE_COG.get(); + } + + private BlockState body() { + return AllBlocks.MILLSTONE.get().getDefaultState(); + } +} diff --git a/src/main/java/com/simibubi/create/config/CClient.java b/src/main/java/com/simibubi/create/config/CClient.java index 67c53c20f..718a2b33d 100644 --- a/src/main/java/com/simibubi/create/config/CClient.java +++ b/src/main/java/com/simibubi/create/config/CClient.java @@ -5,6 +5,8 @@ public class CClient extends ConfigBase { public ConfigGroup client = group(0, "client", "Client-only settings - If you're looking for general settings, look inside your worlds serverconfig folder!"); public ConfigBool tooltips = b(true, "enableTooltips", "Show item descriptions on Shift and controls on Ctrl."); + public ConfigBool enableOverstressedTooltip = + b(true, "enableOverstressedTooltip", "Display a tooltip when looking at overstressed components."); public ConfigBool explainRenderErrors = b(false, "explainRenderErrors", "Log a stack-trace when rendering issues happen within a moving contraption."); public ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity"); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java index 73233dbb4..ff189d48e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntity.java @@ -1,5 +1,6 @@ package com.simibubi.create.modules.contraptions.base; +import static net.minecraft.util.text.TextFormatting.GOLD; import static net.minecraft.util.text.TextFormatting.GRAY; import java.util.List; @@ -19,6 +20,7 @@ import com.simibubi.create.modules.contraptions.RotationPropagator; import com.simibubi.create.modules.contraptions.base.IRotate.SpeedLevel; import com.simibubi.create.modules.contraptions.base.IRotate.StressImpact; import com.simibubi.create.modules.contraptions.goggle.IHaveGoggleInformation; +import com.simibubi.create.modules.contraptions.goggle.IHaveHoveringInformation; import net.minecraft.block.BlockState; import net.minecraft.client.resources.I18n; @@ -33,7 +35,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -public abstract class KineticTileEntity extends SmartTileEntity implements ITickableTileEntity, IHaveGoggleInformation { +public abstract class KineticTileEntity extends SmartTileEntity + implements ITickableTileEntity, IHaveGoggleInformation, IHaveHoveringInformation { public @Nullable Long network; public @Nullable BlockPos source; @@ -353,28 +356,51 @@ public abstract class KineticTileEntity extends SmartTileEntity implements ITick return true; } + @Override + public boolean addToTooltip(List tooltip, boolean isPlayerSneaking) { + boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0; + + if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) { + tooltip.add(spacing + GOLD + Lang.translate("gui.stress_gauge.overstressed")); + String hint = Lang.translate("gui.contraptions.network_overstressed", + I18n.format(getBlockState().getBlock().getTranslationKey())); + List cutString = TooltipHelper.cutString(spacing + hint, GRAY, TextFormatting.WHITE); + for (int i = 0; i < cutString.size(); i++) + tooltip.add((i == 0 ? "" : spacing) + cutString.get(i)); + return true; + } + + if (notFastEnough) { + tooltip.add(spacing + GOLD + Lang.translate("tooltip.speedRequirement")); + String hint = Lang.translate("gui.contraptions.not_fast_enough", + I18n.format(getBlockState().getBlock().getTranslationKey())); + List cutString = TooltipHelper.cutString(spacing + hint, GRAY, TextFormatting.WHITE); + for (int i = 0; i < cutString.size(); i++) + tooltip.add((i == 0 ? "" : spacing) + cutString.get(i)); + return true; + } + + return false; + } + @Override public boolean addToGoggleTooltip(List tooltip, boolean isPlayerSneaking) { boolean added = false; float stressAtBase = getStressApplied(); - boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0; - - if (notFastEnough) { - tooltip.addAll(TooltipHelper.cutString(spacing + Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock().getTranslationKey())), GRAY, TextFormatting.WHITE)); - added = true; - } - - if (getStressApplied() != 0 && StressImpact.isEnabled()){ + if (getStressApplied() != 0 && StressImpact.isEnabled()) { tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats")); tooltip.add(spacing + TextFormatting.GRAY + Lang.translate("tooltip.stressImpact")); float stressTotal = stressAtBase * Math.abs(getSpeed()); - String stressString = spacing + "%s%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s"; + String stressString = + spacing + "%s%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s"; - tooltip.add(String.format(stressString, TextFormatting.AQUA, IHaveGoggleInformation.format(stressAtBase), Lang.translate("gui.goggles.base_value"))); - tooltip.add(String.format(stressString, TextFormatting.GRAY, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed"))); + tooltip.add(String.format(stressString, TextFormatting.AQUA, IHaveGoggleInformation.format(stressAtBase), + Lang.translate("gui.goggles.base_value"))); + tooltip.add(String.format(stressString, TextFormatting.GRAY, IHaveGoggleInformation.format(stressTotal), + Lang.translate("gui.goggles.at_current_speed"))); added = true; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillingRecipe.java b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillingRecipe.java index c9a480b35..be6c6cd56 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillingRecipe.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillingRecipe.java @@ -27,7 +27,7 @@ public class MillingRecipe extends AbstractCrushingRecipe { @Override protected int getMaxOutputCount() { - return 7; + return 4; } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneBlock.java index 28adb70db..71d707646 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneBlock.java @@ -5,14 +5,27 @@ import com.simibubi.create.modules.contraptions.base.KineticBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.InventoryHelper; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.ItemStackHandler; public class MillstoneBlock extends KineticBlock { @@ -29,7 +42,7 @@ public class MillstoneBlock extends KineticBlock { protected boolean hasStaticPart() { return true; } - + @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return AllShapes.MILLSTONE; @@ -39,6 +52,81 @@ public class MillstoneBlock extends KineticBlock { public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == Direction.DOWN; } + + @Override + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + BlockRayTraceResult hit) { + if (!player.getHeldItem(handIn).isEmpty()) + return false; + if (worldIn.getTileEntity(pos) == null) + return false; + if (worldIn.isRemote) + return true; + + TileEntity tileEntity = worldIn.getTileEntity(pos); + if (!(tileEntity instanceof MillstoneTileEntity)) + return false; + MillstoneTileEntity millstone = (MillstoneTileEntity) tileEntity; + + IItemHandlerModifiable inv = millstone.outputInv; + for (int slot = 0; slot < inv.getSlots(); slot++) { + player.inventory.placeItemBackInInventory(worldIn, inv.getStackInSlot(slot)); + inv.setStackInSlot(slot, ItemStack.EMPTY); + } + millstone.markDirty(); + millstone.sendData(); + return true; + } + + @Override + public void onLanded(IBlockReader worldIn, Entity entityIn) { + super.onLanded(worldIn, entityIn); + + if (entityIn.world.isRemote) + return; + if (!(entityIn instanceof ItemEntity)) + return; + + BlockPos pos = entityIn.getPosition(); + TileEntity tileEntity = worldIn.getTileEntity(pos); + if (!(tileEntity instanceof MillstoneTileEntity)) { + tileEntity = worldIn.getTileEntity(pos.down()); + if (!(tileEntity instanceof MillstoneTileEntity)) + return; + } + + MillstoneTileEntity millstone = (MillstoneTileEntity) tileEntity; + ItemEntity itemEntity = (ItemEntity) entityIn; + LazyOptional capability = millstone.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); + if (!capability.isPresent()) + return; + + ItemStack remainder = capability.orElse(new ItemStackHandler()).insertItem(0, itemEntity.getItem(), false); + if (remainder.isEmpty()) + itemEntity.remove(); + if (remainder.getCount() < itemEntity.getItem().getCount()) + itemEntity.setItem(remainder); + } + + @Override + public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { + TileEntity tileEntity = worldIn.getTileEntity(pos); + if (!(tileEntity instanceof MillstoneTileEntity)) + return; + MillstoneTileEntity te = (MillstoneTileEntity) tileEntity; + for (int slot = 0; slot < te.inputInv.getSlots(); slot++) { + InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), + te.inputInv.getStackInSlot(slot)); + } + for (int slot = 0; slot < te.outputInv.getSlots(); slot++) { + InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), + te.outputInv.getStackInSlot(slot)); + } + + worldIn.removeTileEntity(pos); + } + } @Override public boolean hasIntegratedCogwheel(IWorldReader world, BlockPos pos, BlockState state) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneRenderer.java index ff8b12d84..519774db4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneRenderer.java @@ -10,7 +10,7 @@ public class MillstoneRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return CreateClient.bufferCache.renderPartial(AllBlockPartials.MILL_STONE_COG, te.getBlockState()); + return CreateClient.bufferCache.renderPartial(AllBlockPartials.MILLSTONE_COG, te.getBlockState()); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneTileEntity.java index 0059bb366..247272b33 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/millstone/MillstoneTileEntity.java @@ -65,7 +65,6 @@ public class MillstoneTileEntity extends KineticTileEntity { if (lastRecipe == null || !lastRecipe.matches(inventoryIn, world)) { Optional recipe = world.getRecipeManager().getRecipe(AllRecipes.MILLING.getType(), inventoryIn, world); - inputInv.getStackInSlot(0).shrink(1); if (!recipe.isPresent()) { timer = 100; sendData(); @@ -83,9 +82,6 @@ public class MillstoneTileEntity extends KineticTileEntity { private void process() { RecipeWrapper inventoryIn = new RecipeWrapper(inputInv); - ItemStack stackInSlot = inputInv.getStackInSlot(0); - stackInSlot.shrink(1); - inputInv.setStackInSlot(0, stackInSlot); if (lastRecipe == null || !lastRecipe.matches(inventoryIn, world)) { Optional recipe = @@ -95,6 +91,9 @@ public class MillstoneTileEntity extends KineticTileEntity { lastRecipe = recipe.get(); } + ItemStack stackInSlot = inputInv.getStackInSlot(0); + stackInSlot.shrink(1); + inputInv.setStackInSlot(0, stackInSlot); lastRecipe.rollResults().forEach(stack -> ItemHandlerHelper.insertItemStacked(outputInv, stack, false)); sendData(); markDirty(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java index 9a76cd34b..c432d5530 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java @@ -41,17 +41,34 @@ public class GoggleOverlayRenderer { ItemStack goggles = mc.player.getItemStackFromSlot(EquipmentSlotType.HEAD); TileEntity te = world.getTileEntity(pos); - if (!AllItems.GOGGLES.typeOf(goggles)) - return; + boolean goggleInformation = te instanceof IHaveGoggleInformation; + boolean hoveringInformation = te instanceof IHaveHoveringInformation; - if (!(te instanceof IHaveGoggleInformation)) + if (!goggleInformation && !hoveringInformation) return; - IHaveGoggleInformation gte = (IHaveGoggleInformation) te; - List tooltip = new ArrayList<>(); - if (!gte.addToGoggleTooltip(tooltip, mc.player.isSneaking())) + if (goggleInformation && AllItems.GOGGLES.typeOf(goggles)) { + IHaveGoggleInformation gte = (IHaveGoggleInformation) te; + if (!gte.addToGoggleTooltip(tooltip, mc.player.isSneaking())) + goggleInformation = false; + } + + if (hoveringInformation) { + boolean goggleAddedInformation = !tooltip.isEmpty(); + if (goggleAddedInformation) + tooltip.add(""); + IHaveHoveringInformation hte = (IHaveHoveringInformation) te; + if (!hte.addToTooltip(tooltip, mc.player.isSneaking())) + hoveringInformation = false; + if (goggleAddedInformation && !hoveringInformation) + tooltip.remove(tooltip.size() - 1); + } + + if (!goggleInformation && !hoveringInformation) + return; + if (tooltip.isEmpty()) return; GlStateManager.pushMatrix(); @@ -70,7 +87,7 @@ public class GoggleOverlayRenderer { tooltipScreen.init(mc, mc.mainWindow.getScaledWidth(), mc.mainWindow.getScaledHeight()); tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2); - ItemStack item = goggles; + ItemStack item = AllItems.GOGGLES.asStack(); ScreenElementRenderer.render3DItem(() -> { GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0); return item; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/goggle/IHaveHoveringInformation.java b/src/main/java/com/simibubi/create/modules/contraptions/goggle/IHaveHoveringInformation.java new file mode 100644 index 000000000..d830babf0 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/goggle/IHaveHoveringInformation.java @@ -0,0 +1,14 @@ +package com.simibubi.create.modules.contraptions.goggle; + +import java.util.List; + +/* +* Implement this Interface in the TileEntity class that wants to add info to the screen +* */ +public interface IHaveHoveringInformation { + + default boolean addToTooltip(List tooltip, boolean isPlayerSneaking){ + return false; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinOperatingTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinOperatingTileEntity.java index eaa5bb9e4..ec78f988f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinOperatingTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/processing/BasinOperatingTileEntity.java @@ -51,6 +51,8 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity { } public void gatherInputs() { + if (!basinInv.isPresent()) + return; BasinInventory inv = (BasinInventory) basinInv.orElse(null); inputs = new ArrayList<>(); IItemHandlerModifiable inputHandler = inv.getInputHandler(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeBlock.java index 592ecf8a1..bcd1f077b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeBlock.java @@ -6,6 +6,7 @@ import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; +import com.simibubi.create.modules.contraptions.base.IRotate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -25,7 +26,6 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class GaugeBlock extends DirectionalAxisKineticBlock { @@ -65,34 +65,41 @@ public class GaugeBlock extends DirectionalAxisKineticBlock { return Blocks.SPRUCE_PLANKS.getMaterialColor(state, worldIn, pos); } + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + World world = context.getWorld(); + Direction face = context.getFace(); + BlockPos placedOnPos = context.getPos().offset(context.getFace().getOpposite()); + BlockState placedOnState = world.getBlockState(placedOnPos); + Block block = placedOnState.getBlock(); + + if (block instanceof IRotate && ((IRotate) block).hasShaftTowards(world, placedOnPos, placedOnState, face)) { + BlockState toPlace = getDefaultState(); + Direction horizontalFacing = context.getPlacementHorizontalFacing(); + Direction nearestLookingDirection = context.getNearestLookingDirection(); + boolean lookPositive = nearestLookingDirection.getAxisDirection() == AxisDirection.POSITIVE; + if (face.getAxis() == Axis.X) { + toPlace = toPlace.with(FACING, lookPositive ? Direction.NORTH : Direction.SOUTH) + .with(AXIS_ALONG_FIRST_COORDINATE, true); + } else if (face.getAxis() == Axis.Y) { + toPlace = toPlace.with(FACING, horizontalFacing.getOpposite()).with(AXIS_ALONG_FIRST_COORDINATE, + horizontalFacing.getAxis() == Axis.X); + } else { + toPlace = toPlace.with(FACING, lookPositive ? Direction.WEST : Direction.EAST) + .with(AXIS_ALONG_FIRST_COORDINATE, false); + } + + return toPlace; + } + + return super.getStateForPlacement(context); + } + @Override protected boolean hasStaticPart() { return true; } - @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - Direction facing = state.get(FACING).getOpposite(); - BlockPos neighbourPos = pos.offset(facing); - BlockState neighbour = worldIn.getBlockState(neighbourPos); - return Block.hasSolidSide(neighbour, worldIn, neighbourPos, facing.getOpposite()); - } - - @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, - boolean isMoving) { - if (worldIn.isRemote) - return; - - Direction blockFacing = state.get(FACING); - if (fromPos.equals(pos.offset(blockFacing.getOpposite()))) { - if (!isValidPosition(state, worldIn, pos)) { - worldIn.destroyBlock(pos, true); - return; - } - } - } - @Override protected Direction getFacingForPlacement(BlockItemUseContext context) { return context.getFace(); diff --git a/src/main/java/com/simibubi/create/modules/logistics/item/filter/FilterItem.java b/src/main/java/com/simibubi/create/modules/logistics/item/filter/FilterItem.java index bd9d2e4f2..9d8b478c5 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/item/filter/FilterItem.java +++ b/src/main/java/com/simibubi/create/modules/logistics/item/filter/FilterItem.java @@ -58,7 +58,7 @@ public class FilterItem extends Item implements INamedContainerProvider { ItemDescription.add(tooltip, makeSummary); } } - + private List makeSummary(ItemStack filter) { List list = new ArrayList<>(); diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index 9b03596d7..4173464b0 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -269,6 +269,7 @@ "death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock", "create.recipe.crushing": "Crushing", + "create.recipe.milling": "Milling", "create.recipe.splashing": "Bulk Washing", "create.recipe.splashing.fan": "Fan behind Flowing Water", "create.recipe.smokingViaFan": "Bulk Smoking", @@ -400,6 +401,7 @@ "create.gui.stress_gauge.no_rotation": "No Rotation", "create.gui.contraptions.not_fast_enough": "It appears that this %1$s is _not_ rotating with _enough_ _speed_.", + "create.gui.contraptions.network_overstressed": "It appears that this contraption is _overstressed_. Add more sources or _slow_ _down_ the components with a high _stress_ _impact_.", "create.gui.flexcrate.title": "Adjustable Crate", "create.gui.flexcrate.storageSpace": "Storage Space", @@ -849,6 +851,11 @@ "block.create.turntable.tooltip": "TURNTABLE", "block.create.turntable.tooltip.summary": "Turns _Rotational_ _Force_ into refined Motion Sickness.", + + "block.create.millstone.tooltip": "MILLSTONE", + "block.create.millstone.tooltip.summary": "A kinetic component suitable for _grinding_ inserted _materials_. Can be powered by an adjacent cogwheel or by connecting to the shaft at the bottom.", + "block.create.millstone.tooltip.condition1": "When Rotated", + "block.create.millstone.tooltip.behaviour1": "Starts applying _milling_ _recipes_ to any items inserted from the side or the top of the block.", "block.create.crushing_wheel.tooltip": "CRUSHING WHEEL", "block.create.crushing_wheel.tooltip.summary": "Large rotatable wheels that _break_ _down_ anything.", diff --git a/src/main/resources/assets/create/models/block/millstone/inner.json b/src/main/resources/assets/create/models/block/millstone/inner.json index bb8230e10..1a21a6e74 100644 --- a/src/main/resources/assets/create/models/block/millstone/inner.json +++ b/src/main/resources/assets/create/models/block/millstone/inner.json @@ -83,7 +83,9 @@ "north": {"uv": [1, 1.5, 5, 5], "texture": "#5"}, "east": {"uv": [1, 1.5, 5, 5], "texture": "#5"}, "south": {"uv": [1, 1.5, 5, 5], "texture": "#5"}, - "west": {"uv": [1, 1.5, 5, 5], "texture": "#5"} + "west": {"uv": [1, 1.5, 5, 5], "texture": "#5"}, + "up": {"uv": [1, 1, 5, 5], "texture": "#5"}, + "down": {"uv": [1, 1, 5, 5], "texture": "#5"} } }, { diff --git a/src/main/resources/data/create/recipes/crafting_shaped/contraptions/crushing_wheel.json b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/crushing_wheel.json deleted file mode 100644 index abc2e30cc..000000000 --- a/src/main/resources/data/create/recipes/crafting_shaped/contraptions/crushing_wheel.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "type": "crafting_shaped", - "pattern": [ - "ABA", - "BSB", - "ABA" - ], - "key": { - "B": { - "item": "minecraft:polished_andesite" - }, - "A": { - "item": "create:andesite_alloy" - }, - "S": { - "item": "create:large_cogwheel" - } - }, - "result": { - "item": "create:crushing_wheel", - "count": 1 - }, - "conditions": [ - { - "type": "create:module", - "module": "contraptions" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/diamond_horse_armor.json b/src/main/resources/data/create/recipes/crushing/diamond_horse_armor.json similarity index 92% rename from src/main/resources/data/create/recipes/milling/diamond_horse_armor.json rename to src/main/resources/data/create/recipes/crushing/diamond_horse_armor.json index 56c501b18..0b1d66440 100644 --- a/src/main/resources/data/create/recipes/milling/diamond_horse_armor.json +++ b/src/main/resources/data/create/recipes/crushing/diamond_horse_armor.json @@ -1,5 +1,5 @@ { - "type": "create:milling", + "type": "create:crushing", "ingredients": [ { "item": "minecraft:diamond_horse_armor" diff --git a/src/main/resources/data/create/recipes/milling/golden_horse_armor.json b/src/main/resources/data/create/recipes/crushing/golden_horse_armor.json similarity index 94% rename from src/main/resources/data/create/recipes/milling/golden_horse_armor.json rename to src/main/resources/data/create/recipes/crushing/golden_horse_armor.json index 4574bcabf..6ea7d4bcf 100644 --- a/src/main/resources/data/create/recipes/milling/golden_horse_armor.json +++ b/src/main/resources/data/create/recipes/crushing/golden_horse_armor.json @@ -1,5 +1,5 @@ { - "type": "create:milling", + "type": "create:crushing", "ingredients": [ { "item": "minecraft:golden_horse_armor" diff --git a/src/main/resources/data/create/recipes/crushing/gravel.json b/src/main/resources/data/create/recipes/crushing/gravel.json new file mode 100644 index 000000000..7a24b7d2b --- /dev/null +++ b/src/main/resources/data/create/recipes/crushing/gravel.json @@ -0,0 +1,25 @@ +{ + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:gravel" + } + ], + "results": [ + { + "item": "minecraft:sand", + "count": 1 + }, + { + "item": "minecraft:clay_ball", + "count": 1, + "chance": 0.1 + }, + { + "item": "minecraft:flint", + "count": 1, + "chance": 0.2 + } + ], + "processingTime": 250 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/iron_horse_armor.json b/src/main/resources/data/create/recipes/crushing/iron_horse_armor.json similarity index 94% rename from src/main/resources/data/create/recipes/milling/iron_horse_armor.json rename to src/main/resources/data/create/recipes/crushing/iron_horse_armor.json index aeafb2d50..88ba0c780 100644 --- a/src/main/resources/data/create/recipes/milling/iron_horse_armor.json +++ b/src/main/resources/data/create/recipes/crushing/iron_horse_armor.json @@ -1,5 +1,5 @@ { - "type": "create:milling", + "type": "create:crushing", "ingredients": [ { "item": "minecraft:iron_horse_armor" diff --git a/src/main/resources/data/create/recipes/milling/leather_horse_armor.json b/src/main/resources/data/create/recipes/crushing/leather_horse_armor.json similarity index 89% rename from src/main/resources/data/create/recipes/milling/leather_horse_armor.json rename to src/main/resources/data/create/recipes/crushing/leather_horse_armor.json index 21c4494ab..eda689e4d 100644 --- a/src/main/resources/data/create/recipes/milling/leather_horse_armor.json +++ b/src/main/resources/data/create/recipes/crushing/leather_horse_armor.json @@ -1,5 +1,5 @@ { - "type": "create:milling", + "type": "create:crushing", "ingredients": [ { "item": "minecraft:leather_horse_armor" diff --git a/src/main/resources/data/create/recipes/crushing/sand.json b/src/main/resources/data/create/recipes/crushing/sand.json new file mode 100644 index 000000000..8d02bd559 --- /dev/null +++ b/src/main/resources/data/create/recipes/crushing/sand.json @@ -0,0 +1,25 @@ +{ + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:sand" + } + ], + "results": [ + { + "item": "create:limesand", + "count": 1 + }, + { + "item": "create:limesand", + "count": 1, + "chance": 0.5 + }, + { + "item": "minecraft:bone_meal", + "count": 1, + "chance": 0.05 + } + ], + "processingTime": 150 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/mechanical_crafting/crushing_wheel.json b/src/main/resources/data/create/recipes/mechanical_crafting/crushing_wheel.json new file mode 100644 index 000000000..aaaea0924 --- /dev/null +++ b/src/main/resources/data/create/recipes/mechanical_crafting/crushing_wheel.json @@ -0,0 +1,34 @@ +{ + "type": "create:mechanical_crafting", + "pattern": [ + " PPP ", + "PSBSP", + "PBCBP", + "PSBSP", + " PPP " + ], + "key": { + "P": { + "item": "create:andesite_alloy" + }, + "S": { + "tag": "forge:rods/wooden" + }, + "C": { + "item": "create:andesite_casing" + }, + "B": { + "tag": "forge:stone" + } + }, + "result": { + "item": "create:crushing_wheel", + "count": 2 + }, + "conditions": [ + { + "type": "create:module", + "module": "contraptions" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/clay.json b/src/main/resources/data/create/recipes/milling/clay.json index 0ff90e484..cd1aa80a5 100644 --- a/src/main/resources/data/create/recipes/milling/clay.json +++ b/src/main/resources/data/create/recipes/milling/clay.json @@ -14,11 +14,6 @@ "item": "minecraft:clay_ball", "count": 1, "chance": 0.5 - }, - { - "item": "minecraft:flint", - "count": 1, - "chance": 0.2 } ], "processingTime": 50 diff --git a/src/main/resources/data/create/recipes/milling/copper_ore.json b/src/main/resources/data/create/recipes/milling/copper_ore.json new file mode 100644 index 000000000..9b38e4c2a --- /dev/null +++ b/src/main/resources/data/create/recipes/milling/copper_ore.json @@ -0,0 +1,15 @@ +{ + "type": "create:milling", + "ingredients": [ + { + "tag": "forge:ores/copper" + } + ], + "results": [ + { + "item": "create:crushed_copper", + "count": 1 + } + ], + "processingTime": 350 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/gold_ore.json b/src/main/resources/data/create/recipes/milling/gold_ore.json new file mode 100644 index 000000000..1c54dea85 --- /dev/null +++ b/src/main/resources/data/create/recipes/milling/gold_ore.json @@ -0,0 +1,15 @@ +{ + "type": "create:milling", + "ingredients": [ + { + "tag": "forge:ores/gold" + } + ], + "results": [ + { + "item": "create:crushed_gold", + "count": 1 + } + ], + "processingTime": 350 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/gravel.json b/src/main/resources/data/create/recipes/milling/gravel.json index eacdb9296..458acbf33 100644 --- a/src/main/resources/data/create/recipes/milling/gravel.json +++ b/src/main/resources/data/create/recipes/milling/gravel.json @@ -6,19 +6,9 @@ } ], "results": [ - { - "item": "minecraft:sand", - "count": 1 - }, - { - "item": "minecraft:clay_ball", - "count": 1, - "chance": 0.1 - }, { "item": "minecraft:flint", - "count": 1, - "chance": 0.2 + "count": 1 } ], "processingTime": 250 diff --git a/src/main/resources/data/create/recipes/milling/iron_ore.json b/src/main/resources/data/create/recipes/milling/iron_ore.json new file mode 100644 index 000000000..e20c3713f --- /dev/null +++ b/src/main/resources/data/create/recipes/milling/iron_ore.json @@ -0,0 +1,15 @@ +{ + "type": "create:milling", + "ingredients": [ + { + "tag": "forge:ores/iron" + } + ], + "results": [ + { + "item": "create:crushed_iron", + "count": 1 + } + ], + "processingTime": 400 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/milling/sand.json b/src/main/resources/data/create/recipes/milling/sand.json index 68321f4a8..acf76e900 100644 --- a/src/main/resources/data/create/recipes/milling/sand.json +++ b/src/main/resources/data/create/recipes/milling/sand.json @@ -9,16 +9,6 @@ { "item": "create:limesand", "count": 1 - }, - { - "item": "create:limesand", - "count": 1, - "chance": 0.5 - }, - { - "item": "minecraft:bone_meal", - "count": 1, - "chance": 0.05 } ], "processingTime": 150 diff --git a/src/main/resources/data/create/recipes/milling/zinc_ore.json b/src/main/resources/data/create/recipes/milling/zinc_ore.json new file mode 100644 index 000000000..23c066517 --- /dev/null +++ b/src/main/resources/data/create/recipes/milling/zinc_ore.json @@ -0,0 +1,15 @@ +{ + "type": "create:milling", + "ingredients": [ + { + "tag": "forge:ores/zinc" + } + ], + "results": [ + { + "item": "create:crushed_zinc", + "count": 1 + } + ], + "processingTime": 350 +} \ No newline at end of file