use of net.minecraft.stats.RecipeBook in project CumServerPro by MCUmbrella.
the class NetHandlerPlayClient method handleRecipeBook.
public void handleRecipeBook(SPacketRecipeBook packetIn) {
RecipeBook recipebook;
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
recipebook = this.gameController.player.getRecipeBook();
recipebook.setGuiOpen(packetIn.isGuiOpen());
recipebook.setFilteringCraftable(packetIn.isFilteringCraftable());
SPacketRecipeBook.State spacketrecipebook$state = packetIn.getState();
label21: switch(spacketrecipebook$state) {
case REMOVE:
Iterator iterator = packetIn.getRecipes().iterator();
while (true) {
if (!iterator.hasNext()) {
break label21;
}
IRecipe irecipe = (IRecipe) iterator.next();
recipebook.lock(irecipe);
}
case INIT:
packetIn.getRecipes().forEach(recipebook::unlock);
packetIn.getDisplayedRecipes().forEach(recipebook::markNew);
break;
case ADD:
packetIn.getRecipes().forEach((p_194025_2_) -> {
recipebook.unlock(p_194025_2_);
recipebook.markNew(p_194025_2_);
RecipeToast.addOrUpdate(this.gameController.getToastGui(), p_194025_2_);
});
}
RecipeBookClient.ALL_RECIPES.forEach((p_194023_1_) -> {
p_194023_1_.updateKnownRecipes(recipebook);
});
if (this.gameController.currentScreen instanceof IRecipeShownListener) {
((IRecipeShownListener) this.gameController.currentScreen).recipesUpdated();
}
}
use of net.minecraft.stats.RecipeBook in project Minecraft-SlientClient-Hack by YouNeverKnow00.
the class Minecraft method setDimensionAndSpawnPlayer.
public void setDimensionAndSpawnPlayer(int dimension) {
this.world.setInitialSpawnLocation();
this.world.removeAllEntities();
int i = 0;
String s = null;
if (this.player != null) {
i = this.player.getEntityId();
this.world.removeEntity(this.player);
s = this.player.getServerBrand();
}
this.renderViewEntity = null;
EntityPlayerSP entityplayersp = this.player;
this.player = this.playerController.func_192830_a(this.world, this.player == null ? new StatisticsManager() : this.player.getStatFileWriter(), this.player == null ? new RecipeBook() : this.player.func_192035_E());
this.player.getDataManager().setEntryValues(entityplayersp.getDataManager().getAll());
this.player.dimension = dimension;
this.renderViewEntity = this.player;
this.player.preparePlayerToSpawn();
this.player.setServerBrand(s);
this.world.spawnEntityInWorld(this.player);
this.playerController.flipPlayer(this.player);
this.player.movementInput = new MovementInputFromOptions(this.gameSettings);
this.player.setEntityId(i);
this.playerController.setPlayerCapabilities(this.player);
this.player.setReducedDebug(entityplayersp.hasReducedDebug());
if (this.currentScreen instanceof GuiGameOver) {
this.displayGuiScreen((GuiScreen) null);
}
}
use of net.minecraft.stats.RecipeBook in project minecolonies by Minecolonies.
the class PrivateCraftingTeachingTransferHandler method transferRecipe.
@Nullable
@Override
public IRecipeTransferError transferRecipe(final CraftingGUIBuilding craftingGUIBuilding, final IRecipeLayout recipeLayout, final EntityPlayer entityPlayer, final boolean b, final boolean b1) {
final IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();
// indexes that do not fit into the player crafting grid
final Set<Integer> badIndexes = ImmutableSet.of(2, 5, 6, 7, 8);
// compact the crafting grid into a 2x2 area
final Map<Integer, ItemStack> guiIngredients = new HashMap<>();
guiIngredients.put(0, ItemStackUtils.EMPTY);
guiIngredients.put(1, ItemStackUtils.EMPTY);
guiIngredients.put(3, ItemStackUtils.EMPTY);
guiIngredients.put(4, ItemStackUtils.EMPTY);
int inputIndex = 0;
for (final IGuiIngredient<ItemStack> ingredient : itemStackGroup.getGuiIngredients().values()) {
if (ingredient.isInput()) {
if (!ingredient.getAllIngredients().isEmpty()) {
if (badIndexes.contains(inputIndex)) {
final String tooltipMessage = I18n.translateToLocal("jei.tooltip.error.recipe.transfer.too.large.player.inventory");
return handlerHelper.createUserErrorForSlots(tooltipMessage, badIndexes);
}
guiIngredients.put(inputIndex, ingredient.getDisplayedIngredient());
}
inputIndex++;
}
}
final InventoryCrafting craftMatrix = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(final EntityPlayer entityPlayer) {
return false;
}
}, 2, 2);
craftMatrix.setInventorySlotContents(0, guiIngredients.get(0));
craftMatrix.setInventorySlotContents(1, guiIngredients.get(1));
craftMatrix.setInventorySlotContents(2, guiIngredients.get(3));
craftMatrix.setInventorySlotContents(3, guiIngredients.get(4));
final IRecipe recipe = CraftingManager.findMatchingRecipe(craftMatrix, craftingGUIBuilding.getWorldObj());
if (recipe == null) {
return handlerHelper.createInternalError();
}
final RecipeBook book = MineColonies.proxy.getRecipeBookFromPlayer(entityPlayer);
if (craftingGUIBuilding.getWorldObj().getGameRules().getBoolean("doLimitedCrafting") && !craftingGUIBuilding.getPlayer().isCreative() && !book.isUnlocked(recipe)) {
final String tooltipMessage = I18n.translateToLocal(TranslationConstants.COM_MINECOLONIES_COREMOD_COMPAT_JEI_CRAFTIN_TEACHING_UNKNOWN_RECIPE);
return handlerHelper.createUserErrorWithTooltip(tooltipMessage);
}
if (b1) {
final TransferRecipeCrafingTeachingMessage message = new TransferRecipeCrafingTeachingMessage(guiIngredients);
MineColonies.getNetwork().sendToServer(message);
}
return null;
}
use of net.minecraft.stats.RecipeBook in project ElementalSorcery by Yuzunyannn.
the class ContainerSupremeTable method slotChangedCraftingGrid.
// 原版配方混合
@Override
protected void slotChangedCraftingGrid(World world, EntityPlayer player, InventoryCrafting craftMatrix, InventoryCraftResult craftResult) {
for (int i = 9; i < craftMatrix.getSizeInventory(); i++) if (!craftMatrix.getStackInSlot(i).isEmpty()) {
craftResult.setInventorySlotContents(0, ItemStack.EMPTY);
return;
}
ItemStack itemstack = ItemStack.EMPTY;
IRecipe irecipe = CraftingManager.findMatchingRecipe(craftMatrix, world);
RecipeBook book = world.isRemote ? ((EntityPlayerSP) player).getRecipeBook() : ((EntityPlayerMP) player).getRecipeBook();
if (irecipe != null && (!world.getGameRules().getBoolean("doLimitedCrafting") || book.isUnlocked(irecipe))) {
craftResult.setRecipeUsed(irecipe);
itemstack = irecipe.getCraftingResult(craftMatrix);
}
craftResult.setInventorySlotContents(0, itemstack);
}
use of net.minecraft.stats.RecipeBook in project Minecraft-SlientClient-Hack by YouNeverKnow00.
the class NetHandlerPlayClient method func_191980_a.
public void func_191980_a(SPacketRecipeBook p_191980_1_) {
RecipeBook recipebook;
PacketThreadUtil.checkThreadAndEnqueue(p_191980_1_, this, this.gameController);
recipebook = this.gameController.player.func_192035_E();
recipebook.func_192813_a(p_191980_1_.func_192593_c());
recipebook.func_192810_b(p_191980_1_.func_192594_d());
SPacketRecipeBook.State spacketrecipebook$state = p_191980_1_.func_194151_e();
label21: switch(spacketrecipebook$state) {
case REMOVE:
Iterator iterator = p_191980_1_.func_192595_a().iterator();
while (true) {
if (!iterator.hasNext()) {
break label21;
}
IRecipe irecipe = (IRecipe) iterator.next();
recipebook.func_193831_b(irecipe);
}
case INIT:
p_191980_1_.func_192595_a().forEach(recipebook::func_194073_a);
p_191980_1_.func_193644_b().forEach(recipebook::func_193825_e);
break;
case ADD:
p_191980_1_.func_192595_a().forEach((p_194025_2_) -> {
recipebook.func_194073_a(p_194025_2_);
recipebook.func_193825_e(p_194025_2_);
RecipeToast.func_193665_a(this.gameController.func_193033_an(), p_194025_2_);
});
}
RecipeBookClient.field_194087_f.forEach((p_194023_1_) -> {
p_194023_1_.func_194214_a(recipebook);
});
if (this.gameController.currentScreen instanceof IRecipeShownListener) {
((IRecipeShownListener) this.gameController.currentScreen).func_192043_J_();
}
}
Aggregations