Added Quartz Tools and Quartz Knife Recipes
This commit is contained in:
@@ -5,7 +5,7 @@ import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ public class EncodedPatternModelLoader implements IModelLoader<EncodedPatternMod
|
||||
@Override
|
||||
public EncodedPatternModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
modelContents.remove("loader"); // Avoid recursion
|
||||
Identifier baseModel = new Identifier(JSONUtils.getString(modelContents, "baseModel"));
|
||||
Identifier baseModel = new Identifier(JsonHelper.getString(modelContents, "baseModel"));
|
||||
return new EncodedPatternModel(baseModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ import net.minecraft.client.render.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraftforge.client.model.IModelBuilder;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
@@ -109,7 +109,7 @@ public class UVLModelLoader implements IModelLoader<UVLModelLoader.UVLModelWrapp
|
||||
return null;
|
||||
}
|
||||
object = object.get("uvlightmap").getAsJsonObject();
|
||||
return new ImmutablePair<>(JSONUtils.getFloat(object, "sky", 0), JSONUtils.getFloat(object, "block", 0));
|
||||
return new ImmutablePair<>(JsonHelper.getFloat(object, "sky", 0), JsonHelper.getFloat(object, "block", 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class UpgradeableContainer extends AEBaseContainer implements IOptionalSl
|
||||
|
||||
final Inventory pi = this.getPlayerInv();
|
||||
for (int x = 0; x < pi.size(); x++) {
|
||||
final ItemStack pii = pi.getStackInSlot(x);
|
||||
final ItemStack pii = pi.getStack(x);
|
||||
if (!pii.isEmpty() && pii.getItem() instanceof NetworkToolItem) {
|
||||
this.lockPlayerInventorySlot(x);
|
||||
this.tbSlot = x;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public final class FacadeItemGroup extends ItemGroup {
|
||||
|
||||
Item blockItem = b.asItem();
|
||||
if (blockItem != Items.AIR && blockItem.getGroup() != null) {
|
||||
final DefaultedList<ItemStack> tmpList = DefaultedList.create();
|
||||
final DefaultedList<ItemStack> tmpList = DefaultedList.of();
|
||||
b.appendStacks(blockItem.getGroup(), tmpList);
|
||||
for (final ItemStack l : tmpList) {
|
||||
final ItemStack facade = itemFacade.createFacadeForItem(l, false);
|
||||
|
||||
@@ -277,17 +277,6 @@ final class Registration {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void registerRecipeSerializers(RegistryEvent.Register<RecipeSerializer<?>> event) {
|
||||
IForgeRegistry<RecipeSerializer<?>> r = event.getRegistry();
|
||||
|
||||
GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName());
|
||||
InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName());
|
||||
|
||||
FacadeItem facadeItem = (FacadeItem) Api.INSTANCE.definitions().items().facade().item();
|
||||
r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE,
|
||||
InscriberRecipeSerializer.INSTANCE, FacadeRecipe.getSerializer(facadeItem));
|
||||
}
|
||||
|
||||
// FIXME LATER
|
||||
public static void postInit() {
|
||||
final IRegistryContainer registries = AEApi.instance().registries();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
continue;
|
||||
}
|
||||
|
||||
final DefaultedList<ItemStack> list = DefaultedList.create();
|
||||
final DefaultedList<ItemStack> list = DefaultedList.of();
|
||||
mi.appendStacks(mi.getGroup(), list);
|
||||
POSSIBLE_ITEMS.addAll(list);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
if (world.isClient()) {
|
||||
return TypedActionResult.resultPass(player.getStackInHand(hand));
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class MeteoritePlacerItem extends AEBaseItem {
|
||||
return TypedActionResult.resultSuccess(itemStack);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
return super.use(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class MatterCannonDispenseItemBehavior extends ItemDispenserBehavio
|
||||
|
||||
p.updatePosition(p.getX() + dir.xOffset, p.getY() + dir.yOffset, p.getZ() + dir.zOffset);
|
||||
|
||||
dispensedItem = tm.onItemRightClick(w, p, null).getResult();
|
||||
dispensedItem = tm.use(w, p, null).getResult();
|
||||
}
|
||||
}
|
||||
return dispensedItem;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipe> {
|
||||
public void setIngredients(GrinderRecipe recipe, IIngredients ingredients) {
|
||||
ingredients.setInputIngredients(Collections.singletonList(recipe.getIngredient()));
|
||||
List<ItemStack> outputs = new ArrayList<>(3);
|
||||
outputs.add(recipe.getRecipeOutput());
|
||||
outputs.add(recipe.getOutput());
|
||||
for (GrinderOptionalResult optionalResult : recipe.getOptionalResults()) {
|
||||
outputs.add(optionalResult.getResult());
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity player, final Hand hand) {
|
||||
this.clearPattern(player.getStackInHand(hand), player);
|
||||
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseI
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World world, final PlayerEntity player, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||
this.disassembleDrive(player.getStackInHand(hand), world, player);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (p.isInSneakingPose()) {
|
||||
this.encode(p.getStackInHand(hand), p);
|
||||
p.swingArm(hand);
|
||||
p.swingHand(hand);
|
||||
return TypedActionResult.resultSuccess(p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class BiometricCardItem extends AEBaseItem implements IBiometricCard {
|
||||
is = player.getStackInHand(hand);
|
||||
}
|
||||
this.encode(is, (PlayerEntity) target);
|
||||
player.swingArm(hand);
|
||||
player.swingHand(hand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -173,14 +173,14 @@ public class MemoryCardItem extends AEBaseItem implements IMemoryCard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(World w, PlayerEntity player, Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(World w, PlayerEntity player, Hand hand) {
|
||||
if (player.isInSneakingPose()) {
|
||||
if (!w.isClient) {
|
||||
this.clearCard(player, w, hand);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(w, player, hand);
|
||||
return super.use(w, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isClient()) {
|
||||
final HitResult mop = AppEng.proxy.getRTR();
|
||||
|
||||
@@ -133,7 +133,7 @@ public class NetworkToolItem extends AEBaseItem implements IGuiItem, IAEWrench {
|
||||
if (!(te instanceof IGridHost)) {
|
||||
if (bs.rotate(w, pos, Rotation.CLOCKWISE_90) != bs) {
|
||||
bs.neighborUpdate(w, pos, Blocks.AIR, pos, false);
|
||||
p.swingArm(hand);
|
||||
p.swingHand(hand);
|
||||
return !w.isClient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class EntropyManipulatorItem extends AEBasePoweredItem implements IBlockT
|
||||
// Overridden to allow use of the item on WATER and LAVA which are otherwise not
|
||||
// considered for onItemUse
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
final HitResult target = rayTrace(w, p, RayTraceContext.FluidHandling.ANY);
|
||||
|
||||
if (target.getType() != HitResult.Type.BLOCK) {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final @Nullable Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final @Nullable Hand hand) {
|
||||
if (this.getAECurrentPower(p.getStackInHand(hand)) > ENERGY_PER_SHOT) {
|
||||
int shots = 1;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PortableCellItem extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity player, final Hand hand) {
|
||||
ContainerOpener.openContainer(MEPortableCellContainer.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity player, final Hand hand) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity player, final Hand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getStackInHand(hand), w, player, hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.ItemTier;
|
||||
|
||||
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(ItemTier.IRON, 6.0F, -3.1F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* 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.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
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.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.QuartzKnifeContainer;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onItemUse(ItemUsageContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (Platform.isServer() && player != null) {
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, context.getPlayer(),
|
||||
ContainerLocator.forItemUseContext(context));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> onItemRightClick(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
}
|
||||
p.swingArm(hand);
|
||||
return new TypedActionResult<>(ActionResult.SUCCESS, p.getStackInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeRemainder(final ItemStack itemStack) {
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.setDamage(itemStack.getDamage() + 1);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRecipeRemainder(final ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, int playerInventorySlot, final World world,
|
||||
final BlockPos pos) {
|
||||
return new QuartzKnifeObj(is);
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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.ItemTier;
|
||||
|
||||
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(ItemTier.IRON, -1.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.ItemTier;
|
||||
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(ItemTier.IRON, 1, -2.8F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.ItemTier;
|
||||
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(ItemTier.IRON, 1.5F, -3.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.ItemTier;
|
||||
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(ItemTier.IRON, 3, -2.4F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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 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 {
|
||||
|
||||
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.getFace())) {
|
||||
context.getPlayer().swingArm(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;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class PartPlacement {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.swingArm(hand);
|
||||
player.swingHand(hand);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand));
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class PartPlacement {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.swingArm(hand);
|
||||
player.swingHand(hand);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand));
|
||||
return ActionResult.SUCCESS;
|
||||
@@ -252,7 +252,7 @@ public class PartPlacement {
|
||||
|
||||
pass = PlaceType.INTERACT_SECOND_PASS;
|
||||
} else {
|
||||
player.swingArm(hand);
|
||||
player.swingHand(hand);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PartPlacementPacket(pos, side, getEyeOffset(player), hand));
|
||||
return ActionResult.SUCCESS;
|
||||
@@ -319,7 +319,7 @@ public class PartPlacement {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.swingArm(hand);
|
||||
player.swingHand(hand);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class DisassembleRecipe extends SpecialRecipe {
|
||||
ItemStack output = MISMATCHED_STACK;
|
||||
|
||||
for (int slotIndex = 0; slotIndex < inventory.size(); slotIndex++) {
|
||||
final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex);
|
||||
final ItemStack stackInSlot = inventory.getStack(slotIndex);
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
// needs a single input in the recipe
|
||||
itemCount++;
|
||||
|
||||
@@ -56,11 +56,11 @@ public final class FacadeRecipe extends SpecialRecipe {
|
||||
|
||||
@Nonnull
|
||||
private ItemStack getOutput(final Inventory inv, final boolean createFacade) {
|
||||
if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(2).isEmpty() && inv.getStackInSlot(6).isEmpty()
|
||||
&& inv.getStackInSlot(8).isEmpty()) {
|
||||
if (this.anchor.isSameAs(inv.getStackInSlot(1)) && this.anchor.isSameAs(inv.getStackInSlot(3))
|
||||
&& this.anchor.isSameAs(inv.getStackInSlot(5)) && this.anchor.isSameAs(inv.getStackInSlot(7))) {
|
||||
final ItemStack facades = this.facade.createFacadeForItem(inv.getStackInSlot(4), !createFacade);
|
||||
if (inv.getStack(0).isEmpty() && inv.getStack(2).isEmpty() && inv.getStack(6).isEmpty()
|
||||
&& inv.getStack(8).isEmpty()) {
|
||||
if (this.anchor.isSameAs(inv.getStack(1)) && this.anchor.isSameAs(inv.getStack(3))
|
||||
&& this.anchor.isSameAs(inv.getStack(5)) && this.anchor.isSameAs(inv.getStack(7))) {
|
||||
final ItemStack facades = this.facade.createFacadeForItem(inv.getStack(4), !createFacade);
|
||||
if (!facades.isEmpty() && createFacade) {
|
||||
facades.setCount(4);
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
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.getStackInSlot(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack craft(Inventory inv) {
|
||||
// FIXME: What about secondary output
|
||||
return this.result.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
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> getIngredients() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.create();
|
||||
nonnulllist.add(this.ingredient);
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
public List<GrinderOptionalResult> getOptionalResults() {
|
||||
return optionalResults;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
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.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<GrinderRecipe> {
|
||||
|
||||
public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "grinder");
|
||||
}
|
||||
|
||||
private GrinderRecipeSerializer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrinderRecipe read(Identifier recipeId, JsonObject json) {
|
||||
String group = JSONUtils.getString(json, "group", "");
|
||||
JsonObject inputObj = JSONUtils.getJsonObject(json, "input");
|
||||
Ingredient ingredient = Ingredient.deserialize(inputObj);
|
||||
int ingredientCount = 1;
|
||||
if (inputObj.has("count")) {
|
||||
ingredientCount = inputObj.get("count").getAsInt();
|
||||
}
|
||||
|
||||
JsonObject result = JSONUtils.getJsonObject(json, "result");
|
||||
ItemStack primaryResult = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(result, "primary"));
|
||||
JsonArray optionalResultsJson = JSONUtils.getJsonArray(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.deserializeItem(optionalResultJson.getAsJsonObject());
|
||||
float optionalChance = JSONUtils.getFloat(optionalResultJson.getAsJsonObject(), "percentageChance",
|
||||
AEConfig.instance().getOreDoublePercentage()) / 100.0f;
|
||||
optionalResults.add(new GrinderOptionalResult(optionalChance, optionalResultItem));
|
||||
}
|
||||
}
|
||||
|
||||
int turns = JSONUtils.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.read(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.getRecipeOutput());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package appeng.recipes.handlers;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
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) {
|
||||
for (Recipe<Inventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(input) && input.getCount() >= grinderRecipe.getIngredientCount()) {
|
||||
return grinderRecipe;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
for (Recipe<Inventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
|
||||
GrinderRecipe grinderRecipe = (GrinderRecipe) recipe;
|
||||
if (grinderRecipe.getIngredient().test(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
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 canFit(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
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> getIngredients() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.create();
|
||||
nonnulllist.add(this.topOptional);
|
||||
nonnulllist.add(this.middleInput);
|
||||
nonnulllist.add(this.bottomOptional);
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
public Ingredient getMiddleInput() {
|
||||
return middleInput;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public Ingredient getTopOptional() {
|
||||
return topOptional;
|
||||
}
|
||||
|
||||
public Ingredient getBottomOptional() {
|
||||
return bottomOptional;
|
||||
}
|
||||
|
||||
public InscriberProcessType getProcessType() {
|
||||
return processType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
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.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<InscriberRecipe> {
|
||||
|
||||
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "inscriber");
|
||||
}
|
||||
|
||||
private InscriberRecipeSerializer() {
|
||||
}
|
||||
|
||||
private static InscriberProcessType getMode(JsonObject json) {
|
||||
String mode = JSONUtils.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 = JSONUtils.getString(json, "group", "");
|
||||
ItemStack result = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result"));
|
||||
|
||||
// Deserialize the three parts of the input
|
||||
JsonObject ingredients = JSONUtils.getJsonObject(json, "ingredients");
|
||||
Ingredient middle = Ingredient.deserialize(ingredients.get("middle"));
|
||||
Ingredient top = Ingredient.EMPTY;
|
||||
if (ingredients.has("top")) {
|
||||
top = Ingredient.deserialize(ingredients.get("top"));
|
||||
}
|
||||
Ingredient bottom = Ingredient.EMPTY;
|
||||
if (ingredients.has("bottom")) {
|
||||
bottom = Ingredient.deserialize(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.read(buffer);
|
||||
ItemStack result = buffer.readItemStack();
|
||||
Ingredient top = Ingredient.read(buffer);
|
||||
Ingredient bottom = Ingredient.read(buffer);
|
||||
InscriberProcessType mode = buffer.readEnumValue(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.getRecipeOutput());
|
||||
recipe.getTopOptional().write(buffer);
|
||||
recipe.getBottomOptional().write(buffer);
|
||||
buffer.writeEnumValue(recipe.getProcessType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class GrinderBlockEntity extends AEBaseInvBlockEntity implements ICrankab
|
||||
this.points = 0;
|
||||
final InventoryAdaptor sia = new AdaptorFixedInv(new RangedWrapper(this.inv, 3, 6));
|
||||
|
||||
this.addItem(sia, r.getRecipeOutput());
|
||||
this.addItem(sia, r.getOutput());
|
||||
|
||||
for (GrinderOptionalResult optionalResult : r.getOptionalResults()) {
|
||||
final float chance = (Platform.getRandomInt() % 2000) / 2000.0f;
|
||||
|
||||
Reference in New Issue
Block a user