Added Quartz Tools and Quartz Knife Recipes
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class AERecipeType<T extends Recipe<?>> implements RecipeType<T> {
|
||||
private final String id;
|
||||
|
||||
public AERecipeType(Identifier registryName) {
|
||||
this.id = registryName.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,6 @@ public interface AppEng {
|
||||
// modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
||||
// modEventBus.addGenericListener(BlockEntityType.class, registration::registerTileEntities);
|
||||
// modEventBus.addGenericListener(ScreenHandlerType.class, registration::registerContainerTypes);
|
||||
// modEventBus.addGenericListener(RecipeSerializer.class, registration::registerRecipeSerializers);
|
||||
// modEventBus.addGenericListener(Feature.class, registration::registerWorldGen);
|
||||
// modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
|
||||
// modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension);
|
||||
|
||||
@@ -14,8 +14,12 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.network.TargetPoint;
|
||||
import appeng.hooks.ToolItemHook;
|
||||
import appeng.mixins.CriteriaRegisterMixin;
|
||||
import appeng.recipes.handlers.*;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -42,6 +46,8 @@ public abstract class AppEngBase implements AppEng {
|
||||
registerTileEntities();
|
||||
|
||||
registerParticleTypes();
|
||||
registerRecipeTypes();
|
||||
registerRecipeSerializers();
|
||||
|
||||
setupInternalRegistries();
|
||||
|
||||
@@ -80,12 +86,32 @@ public abstract class AppEngBase implements AppEng {
|
||||
Registry.register(Registry.PARTICLE_TYPE, AppEng.makeId("vibrant_fx"), ParticleTypes.VIBRANT);
|
||||
}
|
||||
|
||||
public void registerTileEntities() {
|
||||
private void registerTileEntities() {
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(ITileEntityRegistrationComponent.class)
|
||||
.forEachRemaining(ITileEntityRegistrationComponent::register);
|
||||
}
|
||||
|
||||
private static <T extends Recipe<?>> RecipeType<T> registerRecipeType(String id) {
|
||||
Identifier fullId = AppEng.makeId(id);
|
||||
return Registry.register(Registry.RECIPE_TYPE, fullId, new AERecipeType<>(fullId));
|
||||
}
|
||||
|
||||
private void registerRecipeTypes() {
|
||||
GrinderRecipe.TYPE = registerRecipeType("grinder");
|
||||
InscriberRecipe.TYPE = registerRecipeType("inscriber");
|
||||
}
|
||||
|
||||
private void registerRecipeSerializers() {
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("quartz_knife"), QuartzKnifeRecipeSerializer.INSTANCE);
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("grinder"), GrinderRecipeSerializer.INSTANCE);
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, AppEng.makeId("inscriber"), InscriberRecipeSerializer.INSTANCE);
|
||||
|
||||
// FIXME FABRIC FacadeItem facadeItem = (FacadeItem) Api.INSTANCE.definitions().items().facade().item();
|
||||
// FIXME FABRIC r.registerAll(DisassembleRecipe.SERIALIZER,
|
||||
// FIXME FABRIC FacadeRecipe.getSerializer(facadeItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToAllNearExcept(final PlayerEntity p, final double x, final double y, final double z,
|
||||
final double dist, final World w, final BasePacket packet) {
|
||||
|
||||
@@ -20,11 +20,14 @@ package appeng.core.api.definitions;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.items.tools.quartz.*;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
||||
/**
|
||||
* Internal implementation for the API items
|
||||
@@ -93,57 +96,57 @@ public final class ApiItems implements IItems {
|
||||
private IItemDefinition dummyFluidItem;
|
||||
|
||||
public ApiItems(FeatureFactory registry, ApiMaterials materials) {
|
||||
// FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS);
|
||||
// this.certusQuartzAxe = certusTools
|
||||
// .item("certus_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
|
||||
// this.certusQuartzHoe = certusTools
|
||||
// .item("certus_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
|
||||
// this.certusQuartzShovel = certusTools
|
||||
// .item("certus_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
|
||||
// this.certusQuartzPick = certusTools
|
||||
// .item("certus_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
|
||||
// this.certusQuartzSword = certusTools
|
||||
// .item("certus_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
|
||||
// this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", QuartzWrenchItem::new)
|
||||
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
|
||||
// .build();
|
||||
// this.certusQuartzKnife = certusTools
|
||||
// .item("certus_quartz_cutting_knife",
|
||||
// props -> new QuartzCuttingKnifeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair())
|
||||
// .addFeatures(AEFeature.QUARTZ_KNIFE).build();
|
||||
//
|
||||
// FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS);
|
||||
// this.netherQuartzAxe = netherTools
|
||||
// .item("nether_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
|
||||
// this.netherQuartzHoe = netherTools
|
||||
// .item("nether_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
|
||||
// this.netherQuartzShovel = netherTools
|
||||
// .item("nether_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
|
||||
// this.netherQuartzPick = netherTools
|
||||
// .item("nether_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
|
||||
// this.netherQuartzSword = netherTools
|
||||
// .item("nether_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
|
||||
// this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", QuartzWrenchItem::new)
|
||||
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
|
||||
// .build();
|
||||
// this.netherQuartzKnife = netherTools
|
||||
// .item("nether_quartz_cutting_knife",
|
||||
// props -> new QuartzCuttingKnifeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
// .itemGroup(ItemGroup.TOOLS).props(props -> props.maxStackSize(1).maxDamage(50).setNoRepair())
|
||||
// .addFeatures(AEFeature.QUARTZ_KNIFE).build();
|
||||
//
|
||||
// Consumer<Item.Settings> chargedDefaults = props -> props.maxStackSize(1).maxDamage(32).setNoRepair();
|
||||
FeatureFactory certusTools = registry.features(AEFeature.CERTUS_QUARTZ_TOOLS);
|
||||
this.certusQuartzAxe = certusTools
|
||||
.item("certus_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
|
||||
this.certusQuartzHoe = certusTools
|
||||
.item("certus_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
|
||||
this.certusQuartzShovel = certusTools
|
||||
.item("certus_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
|
||||
this.certusQuartzPick = certusTools
|
||||
.item("certus_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
|
||||
this.certusQuartzSword = certusTools
|
||||
.item("certus_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
|
||||
this.certusQuartzWrench = certusTools.item("certus_quartz_wrench", QuartzWrenchItem::new)
|
||||
.itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
|
||||
.build();
|
||||
this.certusQuartzKnife = certusTools
|
||||
.item("certus_quartz_cutting_knife",
|
||||
props -> new QuartzCuttingKnifeItem(props, AEFeature.CERTUS_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1).maxDamage(50))
|
||||
.addFeatures(AEFeature.QUARTZ_KNIFE).build();
|
||||
|
||||
FeatureFactory netherTools = registry.features(AEFeature.NETHER_QUARTZ_TOOLS);
|
||||
this.netherQuartzAxe = netherTools
|
||||
.item("nether_quartz_axe", props -> new QuartzAxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_AXE).build();
|
||||
this.netherQuartzHoe = netherTools
|
||||
.item("nether_quartz_hoe", props -> new QuartzHoeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_HOE).build();
|
||||
this.netherQuartzShovel = netherTools
|
||||
.item("nether_quartz_shovel", props -> new QuartzSpadeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_SPADE).build();
|
||||
this.netherQuartzPick = netherTools
|
||||
.item("nether_quartz_pickaxe", props -> new QuartzPickaxeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).addFeatures(AEFeature.QUARTZ_PICKAXE).build();
|
||||
this.netherQuartzSword = netherTools
|
||||
.item("nether_quartz_sword", props -> new QuartzSwordItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.COMBAT).addFeatures(AEFeature.QUARTZ_SWORD).build();
|
||||
this.netherQuartzWrench = netherTools.item("nether_quartz_wrench", QuartzWrenchItem::new)
|
||||
.itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1)).addFeatures(AEFeature.QUARTZ_WRENCH)
|
||||
.build();
|
||||
this.netherQuartzKnife = netherTools
|
||||
.item("nether_quartz_cutting_knife",
|
||||
props -> new QuartzCuttingKnifeItem(props, AEFeature.NETHER_QUARTZ_TOOLS))
|
||||
.itemGroup(ItemGroup.TOOLS).props(props -> props.maxCount(1).maxDamage(50))
|
||||
.addFeatures(AEFeature.QUARTZ_KNIFE).build();
|
||||
|
||||
// Consumer<Item.Settings> chargedDefaults = props -> props.maxCount(1).maxDamage(32).setNoRepair();
|
||||
//
|
||||
// FeatureFactory powerTools = registry.features(AEFeature.POWERED_TOOLS);
|
||||
// this.entropyManipulator = powerTools.item("entropy_manipulator", EntropyManipulatorItem::new)
|
||||
@@ -162,19 +165,19 @@ public final class ApiItems implements IItems {
|
||||
// .rendering(new ColorApplicatorItemRendering()).build();
|
||||
//
|
||||
// this.biometricCard = registry.item("biometric_card", BiometricCardItem::new)
|
||||
// .props(props -> props.maxStackSize(1)).features(AEFeature.SECURITY).build();
|
||||
// this.memoryCard = registry.item("memory_card", MemoryCardItem::new).props(props -> props.maxStackSize(1))
|
||||
// .props(props -> props.maxCount(1)).features(AEFeature.SECURITY).build();
|
||||
// this.memoryCard = registry.item("memory_card", MemoryCardItem::new).props(props -> props.maxCount(1))
|
||||
// .features(AEFeature.MEMORY_CARD).build();
|
||||
// this.networkTool = registry.item("network_tool", NetworkToolItem::new)
|
||||
// .props(props -> props.maxStackSize(1).addToolType(FabricToolTags.get("wrench"), 0))
|
||||
// .props(props -> props.maxCount(1).addToolType(FabricToolTags.get("wrench"), 0))
|
||||
// .features(AEFeature.NETWORK_TOOL).build();
|
||||
//
|
||||
// this.cellCreative = registry.item("creative_storage_cell", CreativeStorageCellItem::new)
|
||||
// .props(props -> props.maxStackSize(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build();
|
||||
// this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxStackSize(1))
|
||||
// .props(props -> props.maxCount(1)).features(AEFeature.STORAGE_CELLS, AEFeature.CREATIVE).build();
|
||||
// this.viewCell = registry.item("view_cell", ViewCellItem::new).props(props -> props.maxCount(1))
|
||||
// .features(AEFeature.VIEW_CELL).build();
|
||||
//
|
||||
// Consumer<Item.Settings> storageCellProps = p -> p.maxStackSize(1);
|
||||
// Consumer<Item.Settings> storageCellProps = p -> p.maxCount(1);
|
||||
//
|
||||
// FeatureFactory storageCells = registry.features(AEFeature.STORAGE_CELLS);
|
||||
// this.cell1k = storageCells
|
||||
@@ -243,7 +246,7 @@ public final class ApiItems implements IItems {
|
||||
//
|
||||
// // rv1
|
||||
// this.encodedPattern = registry.item("encoded_pattern", EncodedPatternItem::new)
|
||||
// .props(props -> props.maxStackSize(1)).features(AEFeature.PATTERNS).build();
|
||||
// .props(props -> props.maxCount(1)).features(AEFeature.PATTERNS).build();
|
||||
//
|
||||
// this.coloredPaintBall = createPaintBalls(registry, "_paint_ball", false);
|
||||
// this.coloredLumenPaintBall = createPaintBalls(registry, "_lumen_paint_ball", true);
|
||||
|
||||
@@ -93,6 +93,8 @@ public class SpawnEntityPacket extends BasePacket {
|
||||
|
||||
if (entity != null) {
|
||||
entity.updateTrackedPosition(x, y, z);
|
||||
// NOTE: Vanilla doesn't do this for all spawned entities, but why transfer the velocity???
|
||||
entity.setVelocityClient(velocityX, velocityY, velocityZ);
|
||||
entity.refreshPositionAfterTeleport(x, y, z);
|
||||
entity.pitch = (float)(pitch * 360) / 256.0F;
|
||||
entity.yaw = (float)(yaw * 360) / 256.0F;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzAxeItem extends AxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzAxeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ToolMaterials.IRON, 6.0F, -3.1F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import appeng.mixins.RemainderSetter;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzCuttingKnifeItem(Item.Settings props, final AEFeature type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
// See below for reasoning
|
||||
((RemainderSetter)this).setRecipeRemainder(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isServer()) {
|
||||
// FIXME FABRIC ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
p.swingHand(hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world,
|
||||
final BlockPos pos) {
|
||||
// FIXME FABRIC return new QuartzKnifeObj(is);
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.HoeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzHoeItem extends HoeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzHoeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ToolMaterials.IRON, -2, -1.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzPickaxeItem extends PickaxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzPickaxeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ToolMaterials.IRON, 1, -2.8F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzSpadeItem extends ShovelItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzSpadeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ToolMaterials.IRON, 1.5F, -3.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.SwordItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzSwordItem extends SwordItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzSwordItem(Item.Settings props, AEFeature type) {
|
||||
super(ToolMaterials.IRON, 3, -2.4F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
import appeng.hooks.AEToolItem;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolItem {
|
||||
|
||||
public QuartzWrenchItem(Item.Settings props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
|
||||
if (!context.getPlayer().isInSneakingPose() && Platform
|
||||
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getBlockPos()), context.getPlayer())) {
|
||||
|
||||
Block block = context.getWorld().getBlockState(context.getBlockPos()).getBlock();
|
||||
if (block instanceof AEBaseBlock) {
|
||||
if (Platform.isClient()) {
|
||||
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server.
|
||||
// Fix that in all Block#onItemUseFirst overrides.
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.PASS;
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) {
|
||||
context.getPlayer().swingHand(context.getHand());
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(final ItemStack wrench, final PlayerEntity player, final BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeManager;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(RecipeManager.class)
|
||||
public interface RecipeManagerMixin {
|
||||
|
||||
@Invoker
|
||||
<C extends Inventory, T extends Recipe<C>> Map<Identifier, Recipe<C>> callGetAllOfType(RecipeType<T> type);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public interface RemainderSetter {
|
||||
@Accessor("recipeRemainder")
|
||||
void setRecipeRemainder(Item item);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ShapelessRecipe.class)
|
||||
public interface ShapelessRecipeMixin {
|
||||
|
||||
@Accessor("group")
|
||||
String getGroup();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Describes an optional result of a grinder recipe.
|
||||
*/
|
||||
public class GrinderOptionalResult {
|
||||
private final float chance;
|
||||
private final ItemStack result;
|
||||
|
||||
public GrinderOptionalResult(float chance, ItemStack result) {
|
||||
this.chance = chance;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chance to occur from 0 (0%) to 1 (100%).
|
||||
*/
|
||||
public float getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GrinderRecipe implements Recipe<Inventory> {
|
||||
|
||||
public static RecipeType<GrinderRecipe> TYPE;
|
||||
|
||||
private final Identifier id;
|
||||
private final String group;
|
||||
private final Ingredient ingredient;
|
||||
private final int ingredientCount;
|
||||
private final ItemStack result;
|
||||
private final List<GrinderOptionalResult> optionalResults;
|
||||
private final int turns;
|
||||
|
||||
public GrinderRecipe(Identifier id, String group, Ingredient ingredient, int ingredientCount,
|
||||
ItemStack result, int turns, List<GrinderOptionalResult> optionalResults) {
|
||||
this.id = id;
|
||||
this.group = group;
|
||||
this.ingredient = ingredient;
|
||||
this.ingredientCount = ingredientCount;
|
||||
this.result = result;
|
||||
this.turns = turns;
|
||||
this.optionalResults = ImmutableList.copyOf(optionalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Inventory inv, World worldIn) {
|
||||
return this.ingredient.test(inv.getStack(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(Inventory inv) {
|
||||
// FIXME: What about secondary output
|
||||
return this.result.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fits(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return GrinderRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public int getTurns() {
|
||||
return turns;
|
||||
}
|
||||
|
||||
public int getIngredientCount() {
|
||||
return ingredientCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.of();
|
||||
nonnulllist.add(this.ingredient);
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
public List<GrinderOptionalResult> getOptionalResults() {
|
||||
return optionalResults;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class GrinderRecipeSerializer implements RecipeSerializer<GrinderRecipe> {
|
||||
|
||||
public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer();
|
||||
|
||||
private GrinderRecipeSerializer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrinderRecipe read(Identifier recipeId, JsonObject json) {
|
||||
String group = JsonHelper.getString(json, "group", "");
|
||||
JsonObject inputObj = JsonHelper.getObject(json, "input");
|
||||
Ingredient ingredient = Ingredient.fromJson(inputObj);
|
||||
int ingredientCount = 1;
|
||||
if (inputObj.has("count")) {
|
||||
ingredientCount = inputObj.get("count").getAsInt();
|
||||
}
|
||||
|
||||
JsonObject result = JsonHelper.getObject(json, "result");
|
||||
ItemStack primaryResult = ShapedRecipe.getItemStack(JsonHelper.getObject(result, "primary"));
|
||||
JsonArray optionalResultsJson = JsonHelper.getArray(result, "optional", null);
|
||||
List<GrinderOptionalResult> optionalResults = Collections.emptyList();
|
||||
if (optionalResultsJson != null) {
|
||||
optionalResults = new ArrayList<>(optionalResultsJson.size());
|
||||
for (JsonElement optionalResultJson : optionalResultsJson) {
|
||||
if (!optionalResultJson.isJsonObject()) {
|
||||
throw new IllegalStateException("Entry in optional result list should be an object.");
|
||||
}
|
||||
ItemStack optionalResultItem = ShapedRecipe.getItemStack(optionalResultJson.getAsJsonObject());
|
||||
float optionalChance = JsonHelper.getFloat(optionalResultJson.getAsJsonObject(), "percentageChance",
|
||||
AEConfig.instance().getOreDoublePercentage()) / 100.0f;
|
||||
optionalResults.add(new GrinderOptionalResult(optionalChance, optionalResultItem));
|
||||
}
|
||||
}
|
||||
|
||||
int turns = JsonHelper.getInt(json, "turns", 8);
|
||||
|
||||
return new GrinderRecipe(recipeId, group, ingredient, ingredientCount, primaryResult, turns, optionalResults);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GrinderRecipe read(Identifier recipeId, PacketByteBuf buffer) {
|
||||
|
||||
String group = buffer.readString();
|
||||
Ingredient ingredient = Ingredient.fromPacket(buffer);
|
||||
int ingredientCount = buffer.readVarInt();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
int turns = buffer.readVarInt();
|
||||
int optionalResultsCount = buffer.readVarInt();
|
||||
List<GrinderOptionalResult> optionalResults = new ArrayList<>(optionalResultsCount);
|
||||
for (int i = 0; i < optionalResultsCount; i++) {
|
||||
float chance = buffer.readFloat();
|
||||
ItemStack optionalResult = buffer.readItemStack();
|
||||
optionalResults.add(new GrinderOptionalResult(chance, optionalResult));
|
||||
}
|
||||
|
||||
return new GrinderRecipe(recipeId, group, ingredient, ingredientCount, result, turns, optionalResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buffer, GrinderRecipe recipe) {
|
||||
buffer.writeString(recipe.getGroup());
|
||||
recipe.getIngredient().write(buffer);
|
||||
buffer.writeVarInt(recipe.getIngredientCount());
|
||||
buffer.writeItemStack(recipe.getOutput());
|
||||
buffer.writeVarInt(recipe.getTurns());
|
||||
List<GrinderOptionalResult> optionalResults = recipe.getOptionalResults();
|
||||
buffer.writeVarInt(optionalResults.size());
|
||||
for (GrinderOptionalResult optionalResult : optionalResults) {
|
||||
buffer.writeFloat(optionalResult.getChance());
|
||||
buffer.writeItemStack(optionalResult.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public final class GrinderRecipes {
|
||||
|
||||
private GrinderRecipes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Search all available Grinder recipes for a recipe matching the given input or
|
||||
* null;
|
||||
*/
|
||||
@Nullable
|
||||
public static GrinderRecipe findForInput(World world, ItemStack input) {
|
||||
// FIXME: this is slow, this creates a full copy of the list everytime
|
||||
List<GrinderRecipe> grinderRecipes = world.getRecipeManager().method_30027(GrinderRecipe.TYPE);
|
||||
for (GrinderRecipe recipe : grinderRecipes) {
|
||||
if (recipe.getIngredient().test(input) && input.getCount() >= recipe.getIngredientCount()) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given item stack is an ingredient in any grinder recipe,
|
||||
* disregarding its current size.
|
||||
*/
|
||||
public static boolean isValidIngredient(World world, ItemStack stack) {
|
||||
// FIXME: this is slow, this creates a full copy of the list everytime
|
||||
List<GrinderRecipe> grinderRecipes = world.getRecipeManager().method_30027(GrinderRecipe.TYPE);
|
||||
for (GrinderRecipe recipe : grinderRecipes) {
|
||||
if (recipe.getIngredient().test(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.*;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
public class InscriberRecipe implements Recipe<Inventory> {
|
||||
|
||||
public static RecipeType<InscriberRecipe> TYPE;
|
||||
|
||||
private final Identifier id;
|
||||
private final String group;
|
||||
|
||||
private final Ingredient middleInput;
|
||||
private final Ingredient topOptional;
|
||||
private final Ingredient bottomOptional;
|
||||
private final ItemStack output;
|
||||
private final InscriberProcessType processType;
|
||||
|
||||
public InscriberRecipe(Identifier id, String group, Ingredient middleInput, ItemStack output,
|
||||
Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) {
|
||||
this.id = id;
|
||||
this.group = group;
|
||||
this.middleInput = middleInput;
|
||||
this.output = output;
|
||||
this.topOptional = topOptional;
|
||||
this.bottomOptional = bottomOptional;
|
||||
this.processType = processType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Inventory inv, World worldIn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(Inventory inv) {
|
||||
return this.output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fits(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return InscriberRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.of();
|
||||
nonnulllist.add(this.topOptional);
|
||||
nonnulllist.add(this.middleInput);
|
||||
nonnulllist.add(this.bottomOptional);
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
public Ingredient getMiddleInput() {
|
||||
return middleInput;
|
||||
}
|
||||
|
||||
public Ingredient getTopOptional() {
|
||||
return topOptional;
|
||||
}
|
||||
|
||||
public Ingredient getBottomOptional() {
|
||||
return bottomOptional;
|
||||
}
|
||||
|
||||
public InscriberProcessType getProcessType() {
|
||||
return processType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
public class InscriberRecipeSerializer implements RecipeSerializer<InscriberRecipe> {
|
||||
|
||||
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
|
||||
|
||||
private InscriberRecipeSerializer() {
|
||||
}
|
||||
|
||||
private static InscriberProcessType getMode(JsonObject json) {
|
||||
String mode = JsonHelper.getString(json, "mode", "inscribe");
|
||||
switch (mode) {
|
||||
case "inscribe":
|
||||
return InscriberProcessType.INSCRIBE;
|
||||
case "press":
|
||||
return InscriberProcessType.PRESS;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown mode for inscriber recipe: " + mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InscriberRecipe read(Identifier recipeId, JsonObject json) {
|
||||
|
||||
InscriberProcessType mode = getMode(json);
|
||||
|
||||
String group = JsonHelper.getString(json, "group", "");
|
||||
ItemStack result = ShapedRecipe.getItemStack(JsonHelper.getObject(json, "result"));
|
||||
|
||||
// Deserialize the three parts of the input
|
||||
JsonObject ingredients = JsonHelper.getObject(json, "ingredients");
|
||||
Ingredient middle = Ingredient.fromJson(ingredients.get("middle"));
|
||||
Ingredient top = Ingredient.EMPTY;
|
||||
if (ingredients.has("top")) {
|
||||
top = Ingredient.fromJson(ingredients.get("top"));
|
||||
}
|
||||
Ingredient bottom = Ingredient.EMPTY;
|
||||
if (ingredients.has("bottom")) {
|
||||
bottom = Ingredient.fromJson(ingredients.get("bottom"));
|
||||
}
|
||||
|
||||
return new InscriberRecipe(recipeId, group, middle, result, top, bottom, mode);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public InscriberRecipe read(Identifier recipeId, PacketByteBuf buffer) {
|
||||
String group = buffer.readString();
|
||||
Ingredient middle = Ingredient.fromPacket(buffer);
|
||||
ItemStack result = buffer.readItemStack();
|
||||
Ingredient top = Ingredient.fromPacket(buffer);
|
||||
Ingredient bottom = Ingredient.fromPacket(buffer);
|
||||
InscriberProcessType mode = buffer.readEnumConstant(InscriberProcessType.class);
|
||||
|
||||
return new InscriberRecipe(recipeId, group, middle, result, top, bottom, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(PacketByteBuf buffer, InscriberRecipe recipe) {
|
||||
buffer.writeString(recipe.getGroup());
|
||||
recipe.getMiddleInput().write(buffer);
|
||||
buffer.writeItemStack(recipe.getOutput());
|
||||
recipe.getTopOptional().write(buffer);
|
||||
recipe.getBottomOptional().write(buffer);
|
||||
buffer.writeEnumConstant(recipe.getProcessType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import appeng.items.tools.quartz.QuartzCuttingKnifeItem;
|
||||
import appeng.mixins.ShapelessRecipeMixin;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
/**
|
||||
* An extended version of ShapelessRecipe to support damaging the QuartzKnife whenever it is used to craft something.
|
||||
*/
|
||||
public class QuartzKnifeRecipe extends ShapelessRecipe {
|
||||
|
||||
public QuartzKnifeRecipe(ShapelessRecipe original) {
|
||||
super(
|
||||
original.getId(),
|
||||
((ShapelessRecipeMixin) original).getGroup(),
|
||||
original.getOutput(),
|
||||
original.getPreviewInputs()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return QuartzKnifeRecipeSerializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<ItemStack> getRemainingStacks(CraftingInventory inventory) {
|
||||
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY);
|
||||
|
||||
for (int i = 0; i < defaultedList.size(); ++i) {
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof QuartzCuttingKnifeItem) {
|
||||
// If it still has durability left, put a more damaged one back, otherwise consume
|
||||
int newDamage = stack.getDamage() + 1;
|
||||
if (newDamage < stack.getMaxDamage()) {
|
||||
stack = stack.copy();
|
||||
stack.setDamage(newDamage);
|
||||
defaultedList.set(i, stack);
|
||||
}
|
||||
} else if (item.hasRecipeRemainder()) {
|
||||
defaultedList.set(i, new ItemStack(item.getRecipeRemainder()));
|
||||
}
|
||||
}
|
||||
|
||||
return defaultedList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.recipe.ShapelessRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class QuartzKnifeRecipeSerializer extends ShapelessRecipe.Serializer {
|
||||
|
||||
public static final QuartzKnifeRecipeSerializer INSTANCE = new QuartzKnifeRecipeSerializer();
|
||||
|
||||
@Override
|
||||
public ShapelessRecipe read(Identifier identifier, JsonObject jsonObject) {
|
||||
return new QuartzKnifeRecipe(super.read(identifier, jsonObject));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShapelessRecipe read(Identifier identifier, PacketByteBuf packetByteBuf) {
|
||||
return new QuartzKnifeRecipe(super.read(identifier, packetByteBuf));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,9 @@
|
||||
"package": "appeng.mixins",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"CriteriaRegisterMixin"
|
||||
"CriteriaRegisterMixin",
|
||||
"RemainderSetter",
|
||||
"ShapelessRecipeMixin"
|
||||
],
|
||||
"client": [
|
||||
"ModelsReloadMixin"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"type": "appliedenergistics2:quartz_knife",
|
||||
"result": {
|
||||
"item": "appliedenergistics2:cable_anchor",
|
||||
"count": 3
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"values": ["#forge:ingots/gold", "#forge:ingots/iron"]
|
||||
"values": ["minecraft:gold_ingot", "minecraft:iron_ingot"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user