Added Quartz Tools and Quartz Knife Recipes
This commit is contained in:
@@ -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;
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ 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 net.minecraft.item.ToolMaterials;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
@@ -30,12 +30,12 @@ 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);
|
||||
super(ToolMaterials.IRON, 6.0F, -3.1F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
+9
-37
@@ -18,10 +18,10 @@
|
||||
|
||||
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.item.ItemUsageContext;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -31,11 +31,7 @@ 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 {
|
||||
@@ -44,48 +40,24 @@ public class QuartzCuttingKnifeItem extends AEBaseItem implements IGuiItem {
|
||||
public QuartzCuttingKnifeItem(Item.Settings props, final AEFeature type) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
// See below for reasoning
|
||||
((RemainderSetter)this).setRecipeRemainder(this);
|
||||
}
|
||||
|
||||
@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) {
|
||||
public TypedActionResult<ItemStack> use(final World w, final PlayerEntity p, final Hand hand) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
// FIXME FABRIC ContainerOpener.openContainer(QuartzKnifeContainer.TYPE, p, ContainerLocator.forHand(p, hand));
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
p.swingArm(hand);
|
||||
p.swingHand(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);
|
||||
// FIXME FABRIC return new QuartzKnifeObj(is);
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -21,7 +21,7 @@ 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 net.minecraft.item.ToolMaterials;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
@@ -30,12 +30,12 @@ public class QuartzHoeItem extends HoeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzHoeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, -1.0F, props);
|
||||
super(ToolMaterials.IRON, -2, -1.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTier;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
@@ -30,12 +30,12 @@ public class QuartzPickaxeItem extends PickaxeItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzPickaxeItem(Item.Settings props, final AEFeature type) {
|
||||
super(ItemTier.IRON, 1, -2.8F, props);
|
||||
super(ToolMaterials.IRON, 1, -2.8F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,7 +20,7 @@ package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTier;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.ShovelItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
@@ -30,12 +30,12 @@ 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);
|
||||
super(ToolMaterials.IRON, 1.5F, -3.0F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,7 +20,7 @@ package appeng.items.tools.quartz;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTier;
|
||||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.item.SwordItem;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
@@ -30,12 +30,12 @@ public class QuartzSwordItem extends SwordItem {
|
||||
private final AEFeature type;
|
||||
|
||||
public QuartzSwordItem(Item.Settings props, AEFeature type) {
|
||||
super(ItemTier.IRON, 3, -2.4F, props);
|
||||
super(ToolMaterials.IRON, 3, -2.4F, props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(final ItemStack a, final ItemStack b) {
|
||||
public boolean canRepair(final ItemStack a, final ItemStack b) {
|
||||
return Platform.canRepair(this.type, a, b);
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -18,6 +18,7 @@
|
||||
|
||||
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;
|
||||
@@ -32,7 +33,7 @@ import appeng.block.AEBaseBlock;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class QuartzWrenchItem extends AEBaseItem implements IAEWrench {
|
||||
public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolItem {
|
||||
|
||||
public QuartzWrenchItem(Item.Settings props) {
|
||||
super(props);
|
||||
@@ -52,8 +53,8 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench {
|
||||
}
|
||||
|
||||
AEBaseBlock aeBlock = (AEBaseBlock) block;
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getFace())) {
|
||||
context.getPlayer().swingArm(context.getHand());
|
||||
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) {
|
||||
context.getPlayer().swingHand(context.getHand());
|
||||
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
+5
-5
@@ -44,7 +44,7 @@ public class GrinderRecipe implements Recipe<Inventory> {
|
||||
|
||||
@Override
|
||||
public boolean matches(Inventory inv, World worldIn) {
|
||||
return this.ingredient.test(inv.getStackInSlot(0));
|
||||
return this.ingredient.test(inv.getStack(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,12 +54,12 @@ public class GrinderRecipe implements Recipe<Inventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
public boolean fits(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
public ItemStack getOutput() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ public class GrinderRecipe implements Recipe<Inventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getIngredients() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.create();
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.of();
|
||||
nonnulllist.add(this.ingredient);
|
||||
return nonnulllist;
|
||||
}
|
||||
+14
-21
@@ -13,40 +13,33 @@ 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.recipe.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<GrinderRecipe> {
|
||||
public class GrinderRecipeSerializer 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);
|
||||
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 = JSONUtils.getJsonObject(json, "result");
|
||||
ItemStack primaryResult = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(result, "primary"));
|
||||
JsonArray optionalResultsJson = JSONUtils.getJsonArray(result, "optional", null);
|
||||
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());
|
||||
@@ -54,14 +47,14 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer
|
||||
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",
|
||||
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 = JSONUtils.getInt(json, "turns", 8);
|
||||
int turns = JsonHelper.getInt(json, "turns", 8);
|
||||
|
||||
return new GrinderRecipe(recipeId, group, ingredient, ingredientCount, primaryResult, turns, optionalResults);
|
||||
}
|
||||
@@ -71,7 +64,7 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer
|
||||
public GrinderRecipe read(Identifier recipeId, PacketByteBuf buffer) {
|
||||
|
||||
String group = buffer.readString();
|
||||
Ingredient ingredient = Ingredient.read(buffer);
|
||||
Ingredient ingredient = Ingredient.fromPacket(buffer);
|
||||
int ingredientCount = buffer.readVarInt();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
int turns = buffer.readVarInt();
|
||||
@@ -91,7 +84,7 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer
|
||||
buffer.writeString(recipe.getGroup());
|
||||
recipe.getIngredient().write(buffer);
|
||||
buffer.writeVarInt(recipe.getIngredientCount());
|
||||
buffer.writeItemStack(recipe.getRecipeOutput());
|
||||
buffer.writeItemStack(recipe.getOutput());
|
||||
buffer.writeVarInt(recipe.getTurns());
|
||||
List<GrinderOptionalResult> optionalResults = recipe.getOptionalResults();
|
||||
buffer.writeVarInt(optionalResults.size());
|
||||
+12
-11
@@ -1,12 +1,11 @@
|
||||
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;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public final class GrinderRecipes {
|
||||
|
||||
private GrinderRecipes() {
|
||||
@@ -18,10 +17,11 @@ public final class GrinderRecipes {
|
||||
*/
|
||||
@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;
|
||||
// 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;
|
||||
@@ -32,9 +32,10 @@ public final class GrinderRecipes {
|
||||
* 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)) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
+4
-8
@@ -46,12 +46,12 @@ public class InscriberRecipe implements Recipe<Inventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
public boolean fits(int width, int height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public class InscriberRecipe implements Recipe<Inventory> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedList<Ingredient> getIngredients() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.create();
|
||||
public DefaultedList<Ingredient> getPreviewInputs() {
|
||||
DefaultedList<Ingredient> nonnulllist = DefaultedList.of();
|
||||
nonnulllist.add(this.topOptional);
|
||||
nonnulllist.add(this.middleInput);
|
||||
nonnulllist.add(this.bottomOptional);
|
||||
@@ -83,10 +83,6 @@ public class InscriberRecipe implements Recipe<Inventory> {
|
||||
return middleInput;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public Ingredient getTopOptional() {
|
||||
return topOptional;
|
||||
}
|
||||
+16
-23
@@ -7,29 +7,22 @@ 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.recipe.ShapedRecipe;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializer<?>>
|
||||
implements RecipeSerializer<InscriberRecipe> {
|
||||
public class InscriberRecipeSerializer 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");
|
||||
String mode = JsonHelper.getString(json, "mode", "inscribe");
|
||||
switch (mode) {
|
||||
case "inscribe":
|
||||
return InscriberProcessType.INSCRIBE;
|
||||
@@ -46,19 +39,19 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializ
|
||||
|
||||
InscriberProcessType mode = getMode(json);
|
||||
|
||||
String group = JSONUtils.getString(json, "group", "");
|
||||
ItemStack result = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result"));
|
||||
String group = JsonHelper.getString(json, "group", "");
|
||||
ItemStack result = ShapedRecipe.getItemStack(JsonHelper.getObject(json, "result"));
|
||||
|
||||
// Deserialize the three parts of the input
|
||||
JsonObject ingredients = JSONUtils.getJsonObject(json, "ingredients");
|
||||
Ingredient middle = Ingredient.deserialize(ingredients.get("middle"));
|
||||
JsonObject ingredients = JsonHelper.getObject(json, "ingredients");
|
||||
Ingredient middle = Ingredient.fromJson(ingredients.get("middle"));
|
||||
Ingredient top = Ingredient.EMPTY;
|
||||
if (ingredients.has("top")) {
|
||||
top = Ingredient.deserialize(ingredients.get("top"));
|
||||
top = Ingredient.fromJson(ingredients.get("top"));
|
||||
}
|
||||
Ingredient bottom = Ingredient.EMPTY;
|
||||
if (ingredients.has("bottom")) {
|
||||
bottom = Ingredient.deserialize(ingredients.get("bottom"));
|
||||
bottom = Ingredient.fromJson(ingredients.get("bottom"));
|
||||
}
|
||||
|
||||
return new InscriberRecipe(recipeId, group, middle, result, top, bottom, mode);
|
||||
@@ -68,11 +61,11 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializ
|
||||
@Override
|
||||
public InscriberRecipe read(Identifier recipeId, PacketByteBuf buffer) {
|
||||
String group = buffer.readString();
|
||||
Ingredient middle = Ingredient.read(buffer);
|
||||
Ingredient middle = Ingredient.fromPacket(buffer);
|
||||
ItemStack result = buffer.readItemStack();
|
||||
Ingredient top = Ingredient.read(buffer);
|
||||
Ingredient bottom = Ingredient.read(buffer);
|
||||
InscriberProcessType mode = buffer.readEnumValue(InscriberProcessType.class);
|
||||
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);
|
||||
}
|
||||
@@ -81,10 +74,10 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<RecipeSerializ
|
||||
public void write(PacketByteBuf buffer, InscriberRecipe recipe) {
|
||||
buffer.writeString(recipe.getGroup());
|
||||
recipe.getMiddleInput().write(buffer);
|
||||
buffer.writeItemStack(recipe.getRecipeOutput());
|
||||
buffer.writeItemStack(recipe.getOutput());
|
||||
recipe.getTopOptional().write(buffer);
|
||||
recipe.getBottomOptional().write(buffer);
|
||||
buffer.writeEnumValue(recipe.getProcessType());
|
||||
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"]
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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