use of net.minecraft.item.BedItem in project orion by AntiCope.
the class AutoBedCraft method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (PlayerUtils.getTotalHealth() <= minHealth.get())
return;
if (automatic.get() && isOutOfMaterial() && !alertedNoMats) {
error("Cannot activate auto mode, no material left.");
alertedNoMats = true;
}
if (automatic.get() && needsRefill() && canRefill(true) && !isOutOfMaterial() && !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) {
FindItemResult craftTable = ItemHelper.findCraftTable();
if (!craftTable.found()) {
toggle();
error("No crafting tables in hotbar!");
return;
}
if (debug.get())
info("Searching for nearby crafting tables");
BlockPos tablePos;
tablePos = findCraftingTable();
if (tablePos == null) {
if (debug.get())
info("None nearby, placing table and returning.");
placeCraftingTable(craftTable);
return;
}
if (debug.get())
info("Located usable crafting table, opening and refilling");
openCraftingTable(tablePos);
if (chatInfo.get() && !startedRefill) {
info("Refilling...");
startedRefill = true;
}
didRefill = true;
return;
}
if (didRefill && !needsRefill()) {
if (chatInfo.get())
info("Refill complete.");
didRefill = false;
startedRefill = false;
if (debug.get())
info("Automatic finished.");
}
if (mc.player.currentScreenHandler instanceof CraftingScreenHandler) {
if (!canRefill(false)) {
if (debug.get())
info("Cancelling current refill because canRefill is false");
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
if (isOutOfMaterial()) {
if (chatInfo.get())
error("You are out of material!");
if (disableNoMats.get())
toggle();
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
if (InvHelper.isInventoryFull()) {
if (disableAfter.get())
toggle();
if (closeAfter.get()) {
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
}
if (chatInfo.get() && !automatic.get())
info("Your inventory is full.");
return;
}
List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getResultsForGroup(RecipeBookGroup.CRAFTING_MISC);
for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
if (recipe.getOutput().getItem() instanceof BedItem) {
assert mc.interactionManager != null;
mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
windowClick(currentScreenHandler, 0, SlotActionType.QUICK_MOVE, 1);
}
}
}
}
}
use of net.minecraft.item.BedItem in project Client by MatHax.
the class AutoBedCraft method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (PlayerUtils.getTotalHealth() <= minHealth.get())
return;
if (automatic.get() && isOutOfMaterial() && !alertedNoMats) {
error("Cannot activate auto mode, no material left.");
alertedNoMats = true;
}
if (automatic.get() && needsRefill() && canRefill(true) && !isOutOfMaterial() && !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) {
FindItemResult craftTable = InvUtils.findCraftTable();
if (!craftTable.found()) {
toggle();
error("No crafting tables in hotbar!");
return;
}
BlockPos tablePos;
tablePos = findCraftingTable();
if (tablePos == null) {
placeCraftingTable(craftTable);
return;
}
openCraftingTable(tablePos);
if (chatInfo.get() && !startedRefill) {
info("Refilling...");
startedRefill = true;
}
didRefill = true;
return;
}
if (didRefill && !needsRefill()) {
if (chatInfo.get())
info("Refill complete.");
didRefill = false;
startedRefill = false;
}
if (mc.player.currentScreenHandler instanceof CraftingScreenHandler) {
if (!canRefill(false)) {
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
if (isOutOfMaterial()) {
if (chatInfo.get())
error("You are out of material!");
if (disableNoMats.get())
toggle();
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
return;
}
if (InvUtils.isInventoryFull()) {
if (disableAfter.get())
toggle();
if (closeAfter.get()) {
mc.player.closeHandledScreen();
if (antiDesync.get())
mc.player.getInventory().updateItems();
}
if (chatInfo.get() && !automatic.get())
info("Your inventory is full.");
return;
}
List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getResultsForGroup(RecipeBookGroup.CRAFTING_MISC);
for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
if (recipe.getOutput().getItem() instanceof BedItem) {
assert mc.interactionManager != null;
mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
windowClick(currentScreenHandler, 0, SlotActionType.QUICK_MOVE, 1);
}
}
}
}
}
use of net.minecraft.item.BedItem in project Client by MatHax.
the class BedHud method render.
@Override
public void render(HudRenderer renderer) {
double x = box.getX();
double y = box.getY();
if (isInEditor())
RenderUtils.drawItem(Items.RED_BED.getDefaultStack(), (int) x, (int) y, scale.get(), true);
else if (InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem).count() > 0)
RenderUtils.drawItem(new ItemStack(Items.RED_BED, InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem).count()), (int) x, (int) y, scale.get(), true);
}
Aggregations