Skip to content

Commit

Permalink
Tilling and Pathing (#403)
Browse files Browse the repository at this point in the history
Signed-off-by: shedaniel <daniel@shedaniel.me>
  • Loading branch information
Shnupbups authored and shedaniel committed Aug 22, 2020
1 parent 44e0c35 commit 13b9c66
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface BuiltinPlugin {
Identifier FUEL = new Identifier("minecraft", "plugins/fuel");
Identifier SMITHING = new Identifier("minecraft", "plugins/smithing");
Identifier BEACON = new Identifier("minecraft", "plugins/beacon");
Identifier TILLING = new Identifier("minecraft", "plugins/tilling");
Identifier PATHING = new Identifier("minecraft", "plugins/pathing");
Identifier INFO = new Identifier("roughlyenoughitems", "plugins/information");

static BuiltinPlugin getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
import me.shedaniel.rei.plugin.fuel.DefaultFuelDisplay;
import me.shedaniel.rei.plugin.information.DefaultInformationCategory;
import me.shedaniel.rei.plugin.information.DefaultInformationDisplay;
import me.shedaniel.rei.plugin.pathing.DefaultPathingCategory;
import me.shedaniel.rei.plugin.pathing.DefaultPathingDisplay;
import me.shedaniel.rei.plugin.pathing.DummyShovelItem;
import me.shedaniel.rei.plugin.smelting.DefaultSmeltingDisplay;
import me.shedaniel.rei.plugin.smithing.DefaultSmithingCategory;
import me.shedaniel.rei.plugin.smithing.DefaultSmithingDisplay;
Expand All @@ -59,6 +62,9 @@
import me.shedaniel.rei.plugin.stripping.DefaultStrippingCategory;
import me.shedaniel.rei.plugin.stripping.DefaultStrippingDisplay;
import me.shedaniel.rei.plugin.stripping.DummyAxeItem;
import me.shedaniel.rei.plugin.tilling.DefaultTillingCategory;
import me.shedaniel.rei.plugin.tilling.DefaultTillingDisplay;
import me.shedaniel.rei.plugin.tilling.DummyHoeItem;
import me.shedaniel.rei.utils.CollectionUtils;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down Expand Up @@ -86,7 +92,6 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;

import static me.shedaniel.rei.impl.Internals.attachInstance;
Expand All @@ -107,6 +112,8 @@ public class DefaultPlugin implements REIPluginV0, BuiltinPlugin {
public static final Identifier FUEL = BuiltinPlugin.FUEL;
public static final Identifier SMITHING = BuiltinPlugin.SMITHING;
public static final Identifier BEACON = BuiltinPlugin.BEACON;
public static final Identifier TILLING = BuiltinPlugin.TILLING;
public static final Identifier PATHING = BuiltinPlugin.PATHING;
public static final Identifier INFO = BuiltinPlugin.INFO;
private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png");
private static final Identifier DISPLAY_TEXTURE_DARK = new Identifier("roughlyenoughitems", "textures/gui/display_dark.png");
Expand Down Expand Up @@ -202,6 +209,8 @@ public void registerPluginCategories(RecipeHelper recipeHelper) {
new DefaultStrippingCategory(),
new DefaultSmithingCategory(),
new DefaultBeaconBaseCategory(),
new DefaultTillingCategory(),
new DefaultPathingCategory(),
new DefaultInformationCategory()
);
}
Expand Down Expand Up @@ -255,6 +264,12 @@ public void registerRecipeDisplays(RecipeHelper recipeHelper) {
DummyAxeItem.getStrippedBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getId(b.getKey()))).forEach(set -> {
recipeHelper.registerDisplay(new DefaultStrippingDisplay(EntryStack.create(set.getKey()), EntryStack.create(set.getValue())));
});
DummyHoeItem.getTilledBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getId(b.getKey()))).forEach(set -> {
recipeHelper.registerDisplay(new DefaultTillingDisplay(EntryStack.create(set.getKey()), EntryStack.create(set.getValue().getBlock())));
});
DummyShovelItem.getPathBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getId(b.getKey()))).forEach(set -> {
recipeHelper.registerDisplay(new DefaultPathingDisplay(EntryStack.create(set.getKey()), EntryStack.create(set.getValue().getBlock())));
});
recipeHelper.registerDisplay(new DefaultBeaconBaseDisplay(CollectionUtils.map(Lists.newArrayList(BlockTags.BEACON_BASE_BLOCKS.values()), ItemStack::new)));
}

Expand Down Expand Up @@ -324,6 +339,18 @@ public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(STRIPPING, EntryStack.create(item));
}
}
Tag<Item> hoes = MinecraftClient.getInstance().getNetworkHandler().getTagManager().getItems().getTag(new Identifier("fabric", "hoes"));
if (hoes != null) {
for (Item item : hoes.values()) {
recipeHelper.registerWorkingStations(TILLING, EntryStack.create(item));
}
}
Tag<Item> shovels = MinecraftClient.getInstance().getNetworkHandler().getTagManager().getItems().getTag(new Identifier("fabric", "shovels"));
if (shovels != null) {
for (Item item : shovels.values()) {
recipeHelper.registerWorkingStations(PATHING, EntryStack.create(item));
}
}
recipeHelper.removeAutoCraftButton(FUEL);
recipeHelper.removeAutoCraftButton(COMPOSTING);
recipeHelper.removeAutoCraftButton(BEACON);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
* Copyright (c) 2018, 2019, 2020 shedaniel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package me.shedaniel.rei.plugin.pathing;

import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;

import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.plugin.DefaultPlugin;

import com.google.common.collect.Lists;
import java.util.List;

public class DefaultPathingCategory implements RecipeCategory<DefaultPathingDisplay> {

@Override
public Identifier getIdentifier() {
return DefaultPlugin.PATHING;
}

@Override
public EntryStack getLogo() {
return EntryStack.create(Items.IRON_SHOVEL);
}

@Override
public String getCategoryName() {
return I18n.translate("category.rei.pathing");
}

@Override
public List<Widget> setupDisplay(DefaultPathingDisplay recipeDisplay, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 27, startPoint.y + 4)));
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 5)));
widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5)).entry(recipeDisplay.getIn()).markInput());
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5)).entry(recipeDisplay.getOut()).disableBackground().markInput());
return widgets;
}

@Override
public int getDisplayHeight() {
return 36;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
* Copyright (c) 2018, 2019, 2020 shedaniel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package me.shedaniel.rei.plugin.pathing;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;

import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay;
import me.shedaniel.rei.plugin.DefaultPlugin;

import java.util.Collections;
import java.util.List;

@Environment(EnvType.CLIENT)
public class DefaultPathingDisplay implements RecipeDisplay {
private EntryStack in, out;

public DefaultPathingDisplay(EntryStack in, EntryStack out) {
this.in = in;
this.out = out;
}

public DefaultPathingDisplay(ItemStack in, ItemStack out) {
this.in = EntryStack.create(in);
this.out = EntryStack.create(out);
}

public final EntryStack getIn() {
return in;
}

public final EntryStack getOut() {
return out;
}

@Override
public List<List<EntryStack>> getInputEntries() {
return Collections.singletonList(Collections.singletonList(in));
}

@Override
public List<List<EntryStack>> getResultingEntries() {
return Collections.singletonList(Collections.singletonList(out));
}

@Override
public Identifier getRecipeCategory() {
return DefaultPlugin.PATHING;
}

@Override
public List<List<EntryStack>> getRequiredEntries() {
return getInputEntries();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
* Copyright (c) 2018, 2019, 2020 shedaniel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package me.shedaniel.rei.plugin.pathing;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.ToolMaterial;

import java.util.Map;

public class DummyShovelItem extends ShovelItem {
protected DummyShovelItem(ToolMaterial toolMaterial_1, float float_1, float float_2, Settings item$Settings_1) {
super(toolMaterial_1, float_1, float_2, item$Settings_1);
}

public static Map<Block, BlockState> getPathBlocksMap() {
return PATH_BLOCKSTATES;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* This file is licensed under the MIT License, part of Roughly Enough Items.
* Copyright (c) 2018, 2019, 2020 shedaniel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package me.shedaniel.rei.plugin.tilling;

import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;

import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import me.shedaniel.rei.plugin.DefaultPlugin;

import com.google.common.collect.Lists;
import java.util.List;

public class DefaultTillingCategory implements RecipeCategory<DefaultTillingDisplay> {

@Override
public Identifier getIdentifier() {
return DefaultPlugin.TILLING;
}

@Override
public EntryStack getLogo() {
return EntryStack.create(Items.IRON_HOE);
}

@Override
public String getCategoryName() {
return I18n.translate("category.rei.tilling");
}

@Override
public List<Widget> setupDisplay(DefaultTillingDisplay recipeDisplay, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createArrow(new Point(startPoint.x + 27, startPoint.y + 4)));
widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 5)));
widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5)).entry(recipeDisplay.getIn()).markInput());
widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5)).entry(recipeDisplay.getOut()).disableBackground().markInput());
return widgets;
}

@Override
public int getDisplayHeight() {
return 36;
}

}

0 comments on commit 13b9c66

Please sign in to comment.